-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Port tests in
references.rs
to sqllogictest (#8877)
* Migrate references unit tests to sqllogictest * Remove unused import
- Loading branch information
Showing
3 changed files
with
134 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
########## | ||
## References Tests | ||
########## | ||
|
||
|
||
# Qualified table references | ||
# Query tables with catalog prefix | ||
statement ok | ||
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 '../../testing/data/csv/aggregate_test_100.csv' | ||
|
||
query I | ||
SELECT COUNT(*) FROM aggregate_test_100; | ||
---- | ||
100 | ||
|
||
query I | ||
SELECT COUNT(*) FROM public.aggregate_test_100; | ||
---- | ||
100 | ||
|
||
query I | ||
SELECT COUNT(*) FROM datafusion.public.aggregate_test_100; | ||
---- | ||
100 | ||
|
||
|
||
# Qualified table references and fields | ||
# Query fields with prefixes | ||
statement ok | ||
CREATE TABLE test("f.c1" TEXT, "test.c2" INT, "...." INT) AS VALUES | ||
('foofoo', 1, 10), | ||
('foobar', 2, 20), | ||
('foobaz', 3, 30); | ||
|
||
query error DataFusion error: Schema error: No field named f1\.c1\. Valid fields are test\."f\.c1", test\."test\.c2", test\."\.\.\.\."\. | ||
SELECT f1.c1 FROM test; | ||
|
||
query T | ||
SELECT "f.c1" FROM test | ||
---- | ||
foofoo | ||
foobar | ||
foobaz | ||
|
||
query T | ||
SELECT test."f.c1" FROM test | ||
---- | ||
foofoo | ||
foobar | ||
foobaz | ||
|
||
query II | ||
SELECT "test.c2" AS expr1, test."test.c2" AS expr2 FROM test | ||
---- | ||
1 1 | ||
2 2 | ||
3 3 | ||
|
||
query II | ||
SELECT "....", "...." AS c3 FROM test ORDER BY "...." | ||
---- | ||
10 10 | ||
20 20 | ||
30 30 | ||
|
||
query TT | ||
EXPLAIN (SELECT "....", "...." AS c3 FROM test ORDER BY "...."); | ||
---- | ||
logical_plan | ||
Sort: test..... ASC NULLS LAST | ||
--Projection: test....., test..... AS c3 | ||
----TableScan: test projection=[....] | ||
physical_plan | ||
SortExec: expr=[....@0 ASC NULLS LAST] | ||
--ProjectionExec: expr=[....@0 as ...., ....@0 as c3] | ||
----MemoryExec: partitions=1, partition_sizes=[1] | ||
|
||
|
||
# Partial qualified name | ||
statement ok | ||
CREATE TABLE t1(t1_id INT, t1_name TEXT, t1_int INT) AS VALUES | ||
(11, 'a', 1), | ||
(22, 'b', 2), | ||
(33, 'c', 3), | ||
(44, 'd', 3); | ||
|
||
statement ok | ||
CREATE TABLE t2(t2_id INT, t2_name TEXT, t2_int INT) AS VALUES | ||
(11, 'z', 3), | ||
(22, 'y', 1), | ||
(44, 'x', 3), | ||
(55, 'w', 3); | ||
|
||
query IT | ||
SELECT t1.t1_id, t1_name FROM public.t1; | ||
---- | ||
11 a | ||
22 b | ||
33 c | ||
44 d |