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

Move subset of select tests to sqllogic #4583

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions datafusion/core/tests/sql/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,9 @@ use datafusion::{
};
use tempfile::TempDir;

#[tokio::test]
async fn all_where_empty() -> Result<()> {
let ctx = SessionContext::new();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT *
FROM aggregate_test_100
WHERE 1=2";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec!["++", "++"];
assert_batches_eq!(expected, &actual);
Ok(())
}

#[tokio::test]
async fn select_values_list() -> Result<()> {
let ctx = SessionContext::new();
{
let sql = "VALUES (1)";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------+",
"| column1 |",
"+---------+",
"| 1 |",
"+---------+",
];
assert_batches_eq!(expected, &actual);
}
{
let sql = "VALUES (-1)";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------+",
"| column1 |",
"+---------+",
"| -1 |",
"+---------+",
];
assert_batches_eq!(expected, &actual);
}
{
let sql = "VALUES (2+1,2-1,2>1)";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------+---------+---------+",
"| column1 | column2 | column3 |",
"+---------+---------+---------+",
"| 3 | 1 | true |",
"+---------+---------+---------+",
];
assert_batches_eq!(expected, &actual);
}
{
let sql = "VALUES";
let plan = ctx.create_logical_plan(sql);
Expand All @@ -84,37 +35,11 @@ async fn select_values_list() -> Result<()> {
let plan = ctx.create_logical_plan(sql);
assert!(plan.is_err());
}
{
let sql = "VALUES (1),(2)";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------+",
"| column1 |",
"+---------+",
"| 1 |",
"| 2 |",
"+---------+",
];
assert_batches_eq!(expected, &actual);
}
{
let sql = "VALUES (1),()";
let plan = ctx.create_logical_plan(sql);
assert!(plan.is_err());
}
{
let sql = "VALUES (1,'a'),(2,'b')";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------+---------+",
"| column1 | column2 |",
"+---------+---------+",
"| 1 | a |",
"| 2 | b |",
"+---------+---------+",
];
assert_batches_eq!(expected, &actual);
}
{
let sql = "VALUES (1),(1,2)";
let plan = ctx.create_logical_plan(sql);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/sqllogictests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn check_test_file(filters: &[&str], path: &Path) -> bool {
/// Create a SessionContext, configured for the specific test
async fn context_for_test_file(file_name: &str) -> SessionContext {
match file_name {
"aggregate.slt" => {
"aggregate.slt" | "select.slt" => {
info!("Registering aggregate tables");
let ctx = SessionContext::new();
setup::register_aggregate_tables(&ctx).await;
Expand Down
58 changes: 58 additions & 0 deletions datafusion/core/tests/sqllogictests/test_files/select.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

# 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.

##########
## SELECT Tests
##########

# all where empty
query II
SELECT * FROM aggregate_test_100 WHERE 1=2
----

# Simple values function
query I
VALUES (1)
----
1

# VALUES with a negative values
query I
VALUES (-1)
----
-1

# foo bar
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change this to something meaningful.

query IIC
VALUES (2+1,2-1,2>1)
----
3 1 true

# multiple rows values
query I
VALUES (1),(2)
----
1
2

# multiple rows and columns from VALUES
query IC
VALUES (1,'a'),(2,'b')
----
1 a
2 b