Skip to content

SAMZA-2230: Support for ANY type arguments in udfs that expect strongly typed arguments#1060

Merged
srinipunuru merged 7 commits into
apache:masterfrom
srinipunuru:udf-any.1
Jul 11, 2019
Merged

SAMZA-2230: Support for ANY type arguments in udfs that expect strongly typed arguments#1060
srinipunuru merged 7 commits into
apache:masterfrom
srinipunuru:udf-any.1

Conversation

@srinipunuru
Copy link
Copy Markdown
Contributor

Calcite and hence Samza SQL supports untyped fields of type SamzaSqlFieldType.ANY. Corresponding java type for such fields is Object.

When an UDF expects a strongly typed field and when one of the arguments that is passed is untyped (i.e. ANY ) it fails. And calcite doesn't allow casting the ANY to a well defined type like java does.

To fix this we explicitly cast the untyped arguments to the type that the UDF expects as part of the UDF code generation. Also added a test case that fails without this change.

@SamzaSqlUdf(name = "MyTestObj", description = "Test UDF.")
public class MyTestObjUdf implements ScalarUdf {

private static final Logger LOG = LoggerFactory.getLogger(MyTestUdf.class);
Copy link
Copy Markdown
Contributor

@weiqingy weiqingy May 31, 2019

Choose a reason for hiding this comment

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

Why we use MyTestUdf.class here? What is the relationship between "MyTestObjUdf" class and MyTestUdf class? I saw the method execute(Object value) is deleted from MyTestUdf class.

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 a mistake, I will fix this. there is no relationship between MyTestUdf and MyTestObj. the deleted method in MyTestUDF was unused.

Copy link
Copy Markdown
Contributor

@weiqingy weiqingy left a comment

Choose a reason for hiding this comment

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

LGTM

@srinipunuru srinipunuru merged commit 5071629 into apache:master Jul 11, 2019
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.

3 participants