wuchong commented on a change in pull request #15630: URL: https://github.com/apache/flink/pull/15630#discussion_r619113925
########## File path: docs/content/docs/connectors/table/hive/hive_dialect.md ########## @@ -346,33 +344,84 @@ CREATE FUNCTION function_name AS class_name; DROP FUNCTION [IF EXISTS] function_name; ``` -## DML +## DML & DQL _`Beta`_ -### INSERT +Hive dialect supports a commonly-used subset of Hive's [DML](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML) +and [DQL](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Select). The following lists some examples of +HiveQL supported by the Hive dialect. -```sql -INSERT (INTO|OVERWRITE) [TABLE] table_name [PARTITION partition_spec] SELECT ...; -``` +- [SORT/CLUSTER/DISTRIBUTE BY](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy) +- [Group By](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+GroupBy) +- [Join](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins) +- [Union](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Union) +- [LATERAL VIEW](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+LateralView) +- [Window Functions](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics) +- [SubQueries](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SubQueries) +- [CTE](https://cwiki.apache.org/confluence/display/Hive/Common+Table+Expression) +- [INSERT INTO dest schema](https://issues.apache.org/jira/browse/HIVE-9481) +- [Implicit type conversions](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-AllowedImplicitConversions) + +In order to have better syntax and semantic compatibility, it's highly recommended to use [HiveModule]({{< ref "docs/connectors/table/hive/hive_functions" >}}#use-hive-built-in-functions-via-hivemodule) +and place it first in the module list, so that Hive built-in functions can be picked up during function resolution. + +Hive dialect no longer supports [Flink SQL queries]({{< ref "docs/dev/table/sql/queries" >}}). Please switch to `default` +dialect if you'd like to write in Flink syntax. -The `partition_spec`, if present, can be either a full spec or partial spec. If the `partition_spec` is a partial -spec, the dynamic partition column names can be omitted. +Following is an example of using hive dialect to run some queries. -## DQL +```bash +Flink SQL> load module hive; +[INFO] Execute statement succeed. + +Flink SQL> use modules hive,core; +[INFO] Execute statement succeed. -At the moment, Hive dialect supports the same syntax as Flink SQL for DQLs. Refer to -[Flink SQL queries]({{< ref "docs/dev/table/sql/queries" >}}) for more details. And it's recommended to switch to -`default` dialect to execute DQLs. +Flink SQL> set table.sql-dialect=hive; +[INFO] Session property has been set. + +Flink SQL> select explode(array(1,2,3)); -- call hive udtf ++-----+ +| col | ++-----+ +| 1 | +| 2 | +| 3 | ++-----+ +3 rows in set + +Flink SQL> create table tbl (key int,value string); Review comment: I think we need to create and use a hive catalog before this? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
