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

CREATE TABLE fails with NTILE window function select query #7639

Closed
matthewgapp opened this issue Sep 25, 2023 · 1 comment · Fixed by #8270
Closed

CREATE TABLE fails with NTILE window function select query #7639

matthewgapp opened this issue Sep 25, 2023 · 1 comment · Fixed by #8270
Labels
bug Something isn't working

Comments

@matthewgapp
Copy link
Contributor

matthewgapp commented Sep 25, 2023

Describe the bug

CREATE TABLE fails with a select query that contains a column derived from the NTILE window function

To Reproduce

in the sqllogictest directory, run this in the window.slt file

# this test fails 
# statement ok
CREATE TABLE ntile_table as SELECT NTILE(8) OVER (ORDER BY c4) as ntile_1, NTILE(12) OVER (ORDER BY c12 DESC) AS ntile_2 FROM aggregate_test_100 LIMIT 10

# this test passes 
statement ok
SELECT NTILE(8) OVER (ORDER BY c4) as ntile_1, NTILE(12) OVER (ORDER BY c12 DESC) AS ntile_2 FROM aggregate_test_100 LIMIT 10

Note that the query (select statement) succeeds while the create table ddl version does not.

Expected behavior

The table is successfully created using the DDL. Create table DDL should be compatible with all queries, including queries that contain an NTILE window function.

Additional context

I found this while writing tests for #7638.

@alamb
Copy link
Contributor

alamb commented Sep 25, 2023

For the record the error is: Error during planning: Mismatch between schema and batches

Here is a self contained reproducer

❯ CREATE EXTERNAL TABLE aggregate_test_100 (
  c1  VARCHAR NOT NULL,
  c2  TINYINT NOT NULL,
  c3  SMALLINT NOT NULL,
  c4  SMALLINT,
  c5  INT,
  c6  BIGINT NOT NULL,
  c7  SMALLINT NOT NULL,
  c8  INT NOT NULL,
  c9  BIGINT UNSIGNED NOT NULL,
  c10 VARCHAR NOT NULL,
  c11 FLOAT NOT NULL,
  c12 DOUBLE NOT NULL,
  c13 VARCHAR NOT NULL
)
STORED AS CSV
WITH HEADER ROW
LOCATION './core/tests/data/aggregate_test_100_order_by_c1_asc.csv';
0 rows in set. Query took 0.003 seconds.

❯ CREATE TABLE ntile_table as SELECT NTILE(8) OVER (ORDER BY c4) as ntile_1, NTILE(12) OVER (ORDER BY c12 DESC) AS ntile_2 FROM aggregate_test_100 LIMIT 10;
Error during planning: Mismatch between schema and batches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants