-
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.
[Feature] support describe file (#4995)
To know the columns/types in a file, users has to create an external table, and describe the table. Sometimes the infer schema is wrong for creating table, to make it right, user need to drop the table, and recreate a table with the specify schema. To solve this problem, we add describe file interface in datafusion-clie, With the Describe File, user can know the infer schema is wrong before creating the table. Syntax: Describe file_path, Example: DESCRIBE 'tests/data/aggregate_simple_pipe.csv'; Return: column_name data_type is_nullable c1 Float32 NO c2 Float64 NO c3 Boolean NO Signed-off-by: xyz <a997647204@gmail.com> Signed-off-by: xyz <a997647204@gmail.com>
- Loading branch information
1 parent
9f498bb
commit ab00bc1
Showing
13 changed files
with
193 additions
and
47 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 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 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
64 changes: 64 additions & 0 deletions
64
datafusion/core/tests/sqllogictests/test_files/describe.slt
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,64 @@ | ||
# 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. | ||
|
||
|
||
########## | ||
# Describe internal tables when information_schema is true | ||
########## | ||
|
||
statement ok | ||
set datafusion.catalog.information_schema = true | ||
|
||
statement ok | ||
CREATE external table aggregate_simple(c1 real, c2 double, c3 boolean) STORED as CSV WITH HEADER ROW LOCATION 'tests/data/aggregate_simple.csv'; | ||
|
||
query C1 | ||
DESCRIBE aggregate_simple; | ||
---- | ||
c1 Float32 NO | ||
c2 Float64 NO | ||
c3 Boolean NO | ||
|
||
statement ok | ||
DROP TABLE aggregate_simple; | ||
|
||
########## | ||
# Describe internal tables when information_schema is false | ||
########## | ||
|
||
statement ok | ||
set datafusion.catalog.information_schema = false | ||
|
||
statement ok | ||
CREATE external table aggregate_simple(c1 real, c2 double, c3 boolean) STORED as CSV WITH HEADER ROW LOCATION 'tests/data/aggregate_simple.csv'; | ||
|
||
query C2 | ||
DESCRIBE aggregate_simple; | ||
---- | ||
c1 Float32 NO | ||
c2 Float64 NO | ||
c3 Boolean NO | ||
|
||
statement ok | ||
DROP TABLE aggregate_simple; | ||
|
||
########## | ||
# Describe file (currently we can only describe file in datafusion-cli, fix this after issue (#4850) has been done) | ||
########## | ||
|
||
statement error Error during planning: table 'datafusion.public.tests/data/aggregate_simple.csv' not found | ||
DESCRIBE 'tests/data/aggregate_simple.csv'; |
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 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 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 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 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 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 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
Oops, something went wrong.