Skip to content

Conversation

@zabetak
Copy link
Member

@zabetak zabetak commented Mar 21, 2023

What changes were proposed in this pull request?

Change the implementation of unix_timestamp operators to avoid the AssertionError and infer the return type correctly; always BIGINT.

Break the inheritance relation with SqlAbstractTimeFunction and change the SqlFunctionCategory from TIMEDATE to NUMERIC; unix_timestamp is not a time function since the result is never among DATE, TIME, or TIMESTAMP.

Change the operand type checker to a more truthful implementation; the type checker is not really used at the moment but it is better to have something realistic there instead of null or something completely wrong.

Change the function syntax from FUNCTION_ID to FUNCTION and update some .q.out files. Not a must do but again there is no reason to omit parentheses from a regular function.

Why are the changes needed?

Calls to inferReturnType method for unix_timestamp operators always lead to AssertionError.

Contrary to operand type checking and operand type inference that are not really relevant for Hive (the latter is not using the SqlValidator logic), the return type inference is important since it may kick in some calls to RelBuilder/RexBuilder APIs. Such calls exist in older versions of Hive and are widely used in Calcite's built-in rules.

Does this PR introduce any user-facing change?

In this version no, but in older versions of Hive it can fix queries failing with AssertionError.

How was this patch tested?

mvn test -Dtest=TestSqlOperatorInferReturnType

…amp function

Calls to inferReturnType method for unix_timestamp operators always
lead to AssertionError.

Contrary to operand type checking and operand type inference that are
not really relevant for Hive (the latter is not using the SqlValidator
logic), the return type inference is important since it may kick in
some calls to RelBuilder/RexBuilder APIs. Such calls exist in older
versions of Hive and are widely used in Calcite's built-in rules.

Change the implementation of unix_timestamp operators to avoid the
AssertionError and infer the return type correctly; always BIGINT.

Break the inheritance relation with SqlAbstractTimeFunction and change
the SqlFunctionCategory from TIMEDATE to NUMERIC; unix_timestamp is not
a time function since the result is never among DATE, TIME, or
TIMESTAMP.

Change the operant type checker to a more truthful implementation; the
type checker is not really used at the moment but it is better to have
something realistic there instead of null or something completely
wrong.

Change the function syntax from FUNCTION_ID to FUNCTION and update some
out files. Not a must do but again there is no reason to omit
parentheses from a regular function.
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@kasakrisz kasakrisz left a comment

Choose a reason for hiding this comment

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

LGTM

@zabetak zabetak closed this in b30fe4c Mar 24, 2023
@zabetak zabetak deleted the HIVE-27157 branch March 24, 2023 16:28
henrib pushed a commit to henrib/hive that referenced this pull request Apr 24, 2023
…amp function (Stamatis Zampetakis reviewed by Krisztian Kasa)

Calls to inferReturnType method for unix_timestamp operators always
lead to AssertionError.

Contrary to operand type checking and operand type inference that are
not really relevant for Hive (the latter is not using the SqlValidator
logic), the return type inference is important since it may kick in
some calls to RelBuilder/RexBuilder APIs. Such calls exist in older
versions of Hive and are widely used in Calcite's built-in rules.

Change the implementation of unix_timestamp operators to avoid the
AssertionError and infer the return type correctly; always BIGINT.

Break the inheritance relation with SqlAbstractTimeFunction and change
the SqlFunctionCategory from TIMEDATE to NUMERIC; unix_timestamp is not
a time function since the result is never among DATE, TIME, or
TIMESTAMP.

Change the operant type checker to a more truthful implementation; the
type checker is not really used at the moment but it is better to have
something realistic there instead of null or something completely
wrong.

Change the function syntax from FUNCTION_ID to FUNCTION and update some
out files. Not a must do but again there is no reason to omit
parentheses from a regular function.

Closes apache#4135
yeahyung pushed a commit to yeahyung/hive that referenced this pull request Jul 20, 2023
…amp function (Stamatis Zampetakis reviewed by Krisztian Kasa)

Calls to inferReturnType method for unix_timestamp operators always
lead to AssertionError.

Contrary to operand type checking and operand type inference that are
not really relevant for Hive (the latter is not using the SqlValidator
logic), the return type inference is important since it may kick in
some calls to RelBuilder/RexBuilder APIs. Such calls exist in older
versions of Hive and are widely used in Calcite's built-in rules.

Change the implementation of unix_timestamp operators to avoid the
AssertionError and infer the return type correctly; always BIGINT.

Break the inheritance relation with SqlAbstractTimeFunction and change
the SqlFunctionCategory from TIMEDATE to NUMERIC; unix_timestamp is not
a time function since the result is never among DATE, TIME, or
TIMESTAMP.

Change the operant type checker to a more truthful implementation; the
type checker is not really used at the moment but it is better to have
something realistic there instead of null or something completely
wrong.

Change the function syntax from FUNCTION_ID to FUNCTION and update some
out files. Not a must do but again there is no reason to omit
parentheses from a regular function.

Closes apache#4135
tarak271 pushed a commit to tarak271/hive-1 that referenced this pull request Dec 19, 2023
…amp function (Stamatis Zampetakis reviewed by Krisztian Kasa)

Calls to inferReturnType method for unix_timestamp operators always
lead to AssertionError.

Contrary to operand type checking and operand type inference that are
not really relevant for Hive (the latter is not using the SqlValidator
logic), the return type inference is important since it may kick in
some calls to RelBuilder/RexBuilder APIs. Such calls exist in older
versions of Hive and are widely used in Calcite's built-in rules.

Change the implementation of unix_timestamp operators to avoid the
AssertionError and infer the return type correctly; always BIGINT.

Break the inheritance relation with SqlAbstractTimeFunction and change
the SqlFunctionCategory from TIMEDATE to NUMERIC; unix_timestamp is not
a time function since the result is never among DATE, TIME, or
TIMESTAMP.

Change the operant type checker to a more truthful implementation; the
type checker is not really used at the moment but it is better to have
something realistic there instead of null or something completely
wrong.

Change the function syntax from FUNCTION_ID to FUNCTION and update some
out files. Not a must do but again there is no reason to omit
parentheses from a regular function.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants