From a59a6edbb84a9a65536a1639e209ef5f3fedcfe2 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 1 Apr 2021 08:50:37 -0400 Subject: [PATCH] feat: add SHOW TABLES and `select * from information_schema.columns` (#1102) * chore: update dependencies * test: add tests for new information schema --- Cargo.lock | 9 +++++---- arrow_deps/Cargo.toml | 10 +++++----- server/src/query_tests/sql.rs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f98a591793..7bfed2a46d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrow" version = "4.0.0-SNAPSHOT" -source = "git+https://github.com/apache/arrow.git?rev=9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f#9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f" +source = "git+https://github.com/apache/arrow.git?rev=090f11cf9583a72a967956d383e5d452db17bd96#090f11cf9583a72a967956d383e5d452db17bd96" dependencies = [ "cfg_aliases", "chrono", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "arrow-flight" version = "4.0.0-SNAPSHOT" -source = "git+https://github.com/apache/arrow.git?rev=9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f#9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f" +source = "git+https://github.com/apache/arrow.git?rev=090f11cf9583a72a967956d383e5d452db17bd96#090f11cf9583a72a967956d383e5d452db17bd96" dependencies = [ "arrow", "bytes", @@ -777,7 +777,7 @@ dependencies = [ [[package]] name = "datafusion" version = "4.0.0-SNAPSHOT" -source = "git+https://github.com/apache/arrow.git?rev=9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f#9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f" +source = "git+https://github.com/apache/arrow.git?rev=090f11cf9583a72a967956d383e5d452db17bd96#090f11cf9583a72a967956d383e5d452db17bd96" dependencies = [ "ahash 0.7.2", "arrow", @@ -792,6 +792,7 @@ dependencies = [ "parquet", "paste", "pin-project-lite", + "smallvec", "sqlparser", "tokio", "tokio-stream", @@ -2253,7 +2254,7 @@ dependencies = [ [[package]] name = "parquet" version = "4.0.0-SNAPSHOT" -source = "git+https://github.com/apache/arrow.git?rev=9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f#9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f" +source = "git+https://github.com/apache/arrow.git?rev=090f11cf9583a72a967956d383e5d452db17bd96#090f11cf9583a72a967956d383e5d452db17bd96" dependencies = [ "arrow", "base64 0.12.3", diff --git a/arrow_deps/Cargo.toml b/arrow_deps/Cargo.toml index cc7e45127f..762e0cea9a 100644 --- a/arrow_deps/Cargo.toml +++ b/arrow_deps/Cargo.toml @@ -8,14 +8,14 @@ description = "Apache Arrow / Parquet / DataFusion dependencies for InfluxDB IOx [dependencies] # In alphabetical order # We are using development version of arrow/parquet/datafusion and the dependencies are at the same rev -# The version can be found here: https://github.com/apache/arrow/commit/9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f +# The version can be found here: https://github.com/apache/arrow/commit/090f11cf9583a72a967956d383e5d452db17bd96 # -arrow = { git = "https://github.com/apache/arrow.git", rev = "9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f" , features = ["simd"] } -arrow-flight = { git = "https://github.com/apache/arrow.git", rev = "9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f" } +arrow = { git = "https://github.com/apache/arrow.git", rev = "090f11cf9583a72a967956d383e5d452db17bd96" , features = ["simd"] } +arrow-flight = { git = "https://github.com/apache/arrow.git", rev = "090f11cf9583a72a967956d383e5d452db17bd96" } # Turn off optional datafusion features (function packages) -datafusion = { git = "https://github.com/apache/arrow.git", rev = "9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f", default-features = false } +datafusion = { git = "https://github.com/apache/arrow.git", rev = "090f11cf9583a72a967956d383e5d452db17bd96", default-features = false } # Turn off the "arrow" feature; it currently has a bug that causes the crate to rebuild every time # and we're not currently using it anyway -parquet = { git = "https://github.com/apache/arrow.git", rev = "9aa0f85a2750b7faaf8ad069e05a89b4f8a1754f", default-features = false, features = ["snap", "brotli", "flate2", "lz4", "zstd"] } +parquet = { git = "https://github.com/apache/arrow.git", rev = "090f11cf9583a72a967956d383e5d452db17bd96", default-features = false, features = ["snap", "brotli", "flate2", "lz4", "zstd"] } diff --git a/server/src/query_tests/sql.rs b/server/src/query_tests/sql.rs index afa2189dd5..8dbb9383c2 100644 --- a/server/src/query_tests/sql.rs +++ b/server/src/query_tests/sql.rs @@ -191,6 +191,7 @@ async fn sql_select_from_information_schema_tables() { "| public | iox | h2o | BASE TABLE |", "| public | iox | o2 | BASE TABLE |", "| public | information_schema | tables | VIEW |", + "| public | information_schema | columns | VIEW |", "+---------------+--------------------+------------+------------+", ]; run_sql_test_case!( @@ -198,6 +199,35 @@ async fn sql_select_from_information_schema_tables() { "SELECT * from information_schema.tables", &expected ); + run_sql_test_case!(TwoMeasurementsManyFields {}, "SHOW TABLES", &expected); +} + +#[tokio::test] +async fn sql_select_from_information_schema_columns() { + // validate we have access to information schema for listing columns + // names + let expected = vec![ + "+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+", + "| table_catalog | table_schema | table_name | column_name | ordinal_position | column_default | is_nullable | data_type | character_maximum_length | character_octet_length | numeric_precision | numeric_precision_radix | numeric_scale | datetime_precision | interval_type |", + "+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+", + "| public | iox | h2o | city | 0 | | YES | Utf8 | | 2147483647 | | | | | |", + "| public | iox | h2o | moisture | 1 | | YES | Float64 | | | 24 | 2 | | | |", + "| public | iox | h2o | other_temp | 2 | | YES | Float64 | | | 24 | 2 | | | |", + "| public | iox | h2o | state | 3 | | YES | Utf8 | | 2147483647 | | | | | |", + "| public | iox | h2o | temp | 4 | | YES | Float64 | | | 24 | 2 | | | |", + "| public | iox | h2o | time | 5 | | NO | Int64 | | | | | | | |", + "| public | iox | o2 | city | 0 | | YES | Utf8 | | 2147483647 | | | | | |", + "| public | iox | o2 | reading | 1 | | YES | Float64 | | | 24 | 2 | | | |", + "| public | iox | o2 | state | 2 | | YES | Utf8 | | 2147483647 | | | | | |", + "| public | iox | o2 | temp | 3 | | YES | Float64 | | | 24 | 2 | | | |", + "| public | iox | o2 | time | 4 | | NO | Int64 | | | | | | | |", + "+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+", + ]; + run_sql_test_case!( + TwoMeasurementsManyFields {}, + "SELECT * from information_schema.columns", + &expected + ); } #[tokio::test]