IMPALA-12793: Create JDBC table without data source

This patch changes syntax of creating JDBC table statement as
  CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
  (col_name data_type
    [constraint_specification]
    [COMMENT 'col_comment']
    [, ...]
  )
  [COMMENT 'table_comment']
  STORED BY JDBC
  TBLPROPERTIES ('key1'='value1', 'key2'='value2', ...)

Both "STORED BY JDBC" and "STORED AS JDBC" are acceptable. A table
property '__IMPALA_DATA_SOURCE_NAME' is added to the JDBC table with
value 'impalajdbcdatasource', which is shown in the output of command
'show create table'.
Following required JDBC parameters must be specified as table
properties: database.type, jdbc.url, jdbc.driver, driver.url, and table.
Otherwise, AnalysisException will be thrown.

Testing:
 - Added frontend unit tests for new syntax of creating JDBC table.
 - Updated end-to-end unit tests to create JDBC tables without data
   source.
 - Passed core tests

Change-Id: I765aa86b430246786ad85ab6857cefaf4332c920
Reviewed-on: http://gerrit.cloudera.org:8080/21016
Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
wzhou-code
2024-02-07 08:46:21 -08:00
committed by Impala Public Jenkins
parent 7f190c4625
commit edd1e21493
25 changed files with 476 additions and 323 deletions

View File

@@ -46,12 +46,6 @@ CREATE TABLE alltypes_datasource (
date_col DATE)
PRODUCED BY DATA SOURCE AllTypesDataSource("TestInitString");
DROP DATA SOURCE IF EXISTS JdbcDataSource;
CREATE DATA SOURCE JdbcDataSource
LOCATION '/test-warehouse/data-sources/jdbc-data-source.jar'
CLASS 'org.apache.impala.extdatasource.jdbc.JdbcDataSource'
API_VERSION 'V1';
DROP TABLE IF EXISTS alltypes_jdbc_datasource;
CREATE TABLE alltypes_jdbc_datasource (
id INT,
@@ -65,14 +59,15 @@ CREATE TABLE alltypes_jdbc_datasource (
date_col DATE,
string_col STRING,
timestamp_col TIMESTAMP)
PRODUCED BY DATA SOURCE JdbcDataSource(
'{"database.type":"POSTGRES",
"jdbc.url":"jdbc:postgresql://localhost:5432/functional",
"jdbc.driver":"org.postgresql.Driver",
"driver.url":"/test-warehouse/data-sources/jdbc-drivers/postgresql-jdbc.jar",
"dbcp.username":"hiveuser",
"dbcp.password":"password",
"table":"alltypes"}');
STORED BY JDBC
TBLPROPERTIES (
"database.type"="POSTGRES",
"jdbc.url"="jdbc:postgresql://localhost:5432/functional",
"jdbc.driver"="org.postgresql.Driver",
"driver.url"="/test-warehouse/data-sources/jdbc-drivers/postgresql-jdbc.jar",
"dbcp.username"="hiveuser",
"dbcp.password"="password",
"table"="alltypes");
DROP TABLE IF EXISTS alltypes_jdbc_datasource_2;
CREATE TABLE alltypes_jdbc_datasource_2 (
@@ -87,12 +82,13 @@ CREATE TABLE alltypes_jdbc_datasource_2 (
date_col DATE,
string_col STRING,
timestamp_col TIMESTAMP)
PRODUCED BY DATA SOURCE JdbcDataSource(
'{"database.type":"POSTGRES",
"jdbc.url":"jdbc:postgresql://localhost:5432/functional",
"jdbc.driver":"org.postgresql.Driver",
"driver.url":"hdfs://localhost:20500/test-warehouse/data-sources/jdbc-drivers/postgresql-jdbc.jar",
"dbcp.username":"hiveuser",
"dbcp.password":"password",
"table":"AllTypesWithQuote",
"column.mapping":"id=id, bool_col=Bool_col, tinyint_col=Tinyint_col, smallint_col=Smallint_col, int_col=Int_col, bigint_col=Bigint_col, float_col=Float_col, double_col=Double_col, date_string_col=Date_string_col, string_col=String_col, timestamp=Timestamp"}');
STORED BY JDBC
TBLPROPERTIES (
"database.type"="POSTGRES",
"jdbc.url"="jdbc:postgresql://localhost:5432/functional",
"jdbc.driver"="org.postgresql.Driver",
"driver.url"="hdfs://localhost:20500/test-warehouse/data-sources/jdbc-drivers/postgresql-jdbc.jar",
"dbcp.username"="hiveuser",
"dbcp.password"="password",
"table"="AllTypesWithQuote",
"column.mapping"="id=id, bool_col=Bool_col, tinyint_col=Tinyint_col, smallint_col=Smallint_col, int_col=Int_col, bigint_col=Bigint_col, float_col=Float_col, double_col=Double_col, date_string_col=Date_string_col, string_col=String_col, timestamp=Timestamp");