Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusts EXTRACT tests to assert on result in statement #84

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

alancai98
Copy link
Member

@alancai98 alancai98 commented Apr 13, 2023

Related to first part of #83.

Adjusts the EXTRACT builtin function tests to assert on the expected result in the PartiQL statement. This is to deal with the SQL specification's ambiguity related to the output type of EXTRACT. In SQL:2011 (pg 1337):

The declared type of <extract expression> is an implementation-defined exact numeric type. If <primary
datetime field> specifies SECOND, then the scale is implementation-defined; otherwise, the scale is
0 (zero).

where "exact numeric type" refers to "NUMERIC, DECIMAL, SMALLINT, INTEGER, and BIGINT" (pg 15).

Rather than defining the exact numeric type output by EXTRACT to be a decimal or integer, we add a PartiQL equality expression to assert the equivalent value.

E.g. rewrite

{
  ...
  statement:"EXTRACT(YEAR FROM DATE '2023-04-13')",
  assert:{
    ...
    output:2023
  }
},

as

{
  ...
  statement:"EXTRACT(YEAR FROM DATE '2023-04-13') = 2023",
  assert:{
    ...
    output:true
  }
},

This PR also adds some more tests that were omitted from the earlier test porting.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@alancai98 alancai98 self-assigned this Apr 13, 2023
@alancai98
Copy link
Member Author

Same number of tests pass with the Kotlin implementation (other than the MISSING propagation in LEGACY/STRICT typing mode)

@alancai98 alancai98 merged commit fdf35b4 into main Apr 17, 2023
@alancai98 alancai98 deleted the adjusts-extract-tests branch April 17, 2023 17:52
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