Skip to content

IGNITE-29031 SQL Calcite: Support byte[] in UDF and UDTF parameters and results - #13543

Open
tkalkirill wants to merge 2 commits into
masterfrom
ignite-29031
Open

IGNITE-29031 SQL Calcite: Support byte[] in UDF and UDTF parameters and results#13543
tkalkirill wants to merge 2 commits into
masterfrom
ignite-29031

Conversation

@tkalkirill

Copy link
Copy Markdown
Contributor

@zstan

zstan commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

First of all you need to follow the common process [1] i.e. make a PR from your own ignite mirror, not from origin = https://github.com/apache but from: https://github.com/tkalkirill/ignite

[1] https://cwiki.apache.org/confluence/spaces/IGNITE/pages/177047163/How+to+Contribute#HowtoContribute-GITworkflow

@tkalkirill

Copy link
Copy Markdown
Contributor Author

@zstan Okay, subsequent tickets will do as described.

Object[] convertedRow = row;

for (int i = 0; i < row.length; i++) {
if (row[i] instanceof byte[] && SqlTypeUtil.isBinary(rowType.getFieldList().get(i).getType())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. we already have common converter : TypeUtils#toInternal - it need to be used
  2. explain why do you need row.clone() ? .toArray() - already produced a new array.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to fix them.

/** */
private static Function<Object, Object> fieldConverter(ExecutionContext<?> ectx, RelDataType fieldType) {
Type storageType = ectx.getTypeFactory().getJavaClass(fieldType);
Type storageType = SqlTypeUtil.isBinary(fieldType) ? byte[].class : ectx.getTypeFactory().getJavaClass(fieldType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz explain why do we need changes in this class ? All changes need to be covered by tests, i miss them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was needed because the previous implementation was only for a byte[], now it is not needed, I got rid of it.

}

/** Prevents Calcite from evaluating binary literals while deriving a table function row type. */
private static FunctionParameter sqlBinaryParameter(FunctionParameter delegate) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a hack as for me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is only needed when a byte[] table-function argument is a binary literal, for example binaryTableLength(x'010203'). Calcite tries to materialize the literal as byte[] during row-type inference, before the runtime converter is involved. Dynamic parameters and other non-literal expressions work without this workaround.

Would you prefer that we drop binary-literal support from this fix and address it separately if needed, or keep the workaround with an explanatory comment and a dedicated test?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to revise this approach, if it`s hard to implement now - let`s fill an additional issue, thanks !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing with temporal types, it turned out that this is currently necessary and does not work without it.


/** */
@Test
public void testBinaryFunctions() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that this PR need to cover only byte[], what about temporal types ? BO, appropriate tests need to be appended.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added quite a lot of tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants