Skip to content

Move tests from expr.rs to sqllogictests. Part1#8773

Merged
comphead merged 3 commits into
apache:mainfrom
comphead:dev0
Jan 8, 2024
Merged

Move tests from expr.rs to sqllogictests. Part1#8773
comphead merged 3 commits into
apache:mainfrom
comphead:dev0

Conversation

@comphead

@comphead comphead commented Jan 6, 2024

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes partially #8201.

Rationale for this change

Move tests from expr.rs to sqllogictests. Moved most of tests, other tests need more per-test attenttion

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jan 6, 2024
-- out of bounds
([5,4,3,2,1])[0],
([5,4,3,2,1])[6],
-- ([5,4,3,2,1])[-1], -- TODO: wrong answer

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.

seem like we can return the correct answer

DataFusion CLI v34.0.0
❯ select [1,2,3,4][-1];
+------------------------------------------------------------+
| make_array(Int64(1),Int64(2),Int64(3),Int64(4))[Int64(-1)] |
+------------------------------------------------------------+
| 4                                                          |
+------------------------------------------------------------+
1 row in set. Query took 0.019 seconds.

❯ select [1,2,3,4][-4];
+------------------------------------------------------------+
| make_array(Int64(1),Int64(2),Int64(3),Int64(4))[Int64(-4)] |
+------------------------------------------------------------+
| 1                                                          |
+------------------------------------------------------------+
1 row in set. Query took 0.001 seconds.

❯ select [1,2,3,4][-5] is null;
+--------------------------------------------------------------------+
| make_array(Int64(1),Int64(2),Int64(3),Int64(4))[Int64(-5)] IS NULL |
+--------------------------------------------------------------------+
| true                                                               |
+--------------------------------------------------------------------+
1 row in set. Query took 0.001 seconds.

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.

I have checked with PG

select (array[1,2,3,4])[-1]
null

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.

I'll create a followup issue to be in sync with PG

@alamb alamb left a comment

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.

Epic work @comphead -- and thank you for the review @haohuaijin

There was one test I couldn't find ported but otherwise things look great here

[true, false],
['str1', 'str2'],
[[1,2], [3,4]],
[]

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.

💯 for adding the test that was commented out in the rs test

Comment thread datafusion/sqllogictest/test_files/expr.slt
0 years 12 mons 1 days 1 hours 1 mins 1.000000000 secs

query I
SELECT ascii('')

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 actually prefer this style (one query per expression) rather than the style earlier in the PR of one query with all the expressions as I find the output easier to understand

query T
SELECT chr(CAST(128175 AS int))
----
💯

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.

nice!

Ok(())
}

/// Test string expressions test split into two batches

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.

it is sweet that that this is no longer a problem with sqllogictest (though to be fair this code should probably have been using functions rather than macros)

Comment thread datafusion/sqllogictest/test_files/expr.slt
comphead and others added 2 commits January 8, 2024 13:59
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants