Skip to content

Commit

Permalink
[FLINK-26681][hive] Support sql end with ";" for Hive dialect
Browse files Browse the repository at this point in the history
This closes apache#19105
  • Loading branch information
luoyuxia authored and beyond1920 committed Apr 12, 2022
1 parent f089a99 commit 36660cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ catch (RecognitionException e) {

// starting rule
statement
: explainStatement EOF
| execStatement EOF
: explainStatement SEMICOLON? EOF
| execStatement SEMICOLON? EOF
;

explainStatement
Expand Down
28 changes: 27 additions & 1 deletion flink-table/flink-sql-client/src/test/resources/sql/set.q
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,25 @@
# limitations under the License.

# test set a configuration
SET 'sql-client.execution.result-mode' = 'tableau';
[INFO] Session property has been set.
!info

SET 'table.sql-dialect' = 'hive';
[INFO] Session property has been set.
!info

create catalog hivecatalog with (
'type' = 'hive-test',
'hive-version' = '2.3.4'
);
[INFO] Execute statement succeed.
!info

use catalog hivecatalog;
[INFO] Execute statement succeed.
!info

# test create a hive table to verify the configuration works
CREATE TABLE hive_table (
product_id STRING,
Expand All @@ -28,14 +43,24 @@ CREATE TABLE hive_table (
pv_count BIGINT,
like_count BIGINT,
comment_count BIGINT,
update_time TIMESTAMP(3),
update_time TIMESTAMP,
update_user STRING
) PARTITIONED BY (pt_year STRING, pt_month STRING, pt_day STRING) TBLPROPERTIES (
'streaming-source.enable' = 'true'
);
[INFO] Execute statement succeed.
!info

# test "ctas" only supported in Hive Dialect
CREATE TABLE foo as select 1;
+-------------------------+
| hivecatalog.default.foo |
+-------------------------+
| -1 |
+-------------------------+
1 row in set
!ok

# list the configured configuration
set;
'execution.attached' = 'true'
Expand All @@ -47,6 +72,7 @@ set;
'pipeline.classpaths' = ''
'pipeline.jars' = ''
'rest.port' = '$VAR_REST_PORT'
'sql-client.execution.result-mode' = 'tableau'
'table.exec.legacy-cast-behaviour' = 'DISABLED'
'table.sql-dialect' = 'hive'
!ok
Expand Down

0 comments on commit 36660cc

Please sign in to comment.