You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/22 12:34:16 UTC

[GitHub] [flink] luoyuxia opened a new pull request, #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

luoyuxia opened a new pull request, #19556:
URL: https://github.com/apache/flink/pull/19556

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
   
   
   ## Brief change log
   
   *(for example:)*
     - *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
     - *Deployments RPC transmits only the blob storage reference*
     - *TaskManagers retrieve the TaskInfo from the blob cache*
   
   
   ## Verifying this change
   
   Please make sure both new and modified tests in this PR follows the conventions defined in our code quality guide: https://flink.apache.org/contributing/code-style-and-quality-common.html#testing
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (100MB)*
     - *Extended integration test for recovery after master (JobManager) failure*
     - *Added test that validates that TaskInfo is transferred only once across recoveries*
     - *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] luoyuxia commented on pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
luoyuxia commented on PR #19556:
URL: https://github.com/apache/flink/pull/19556#issuecomment-1208716644

   @flinkbot run azure


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] wuchong commented on a diff in pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
wuchong commented on code in PR #19556:
URL: https://github.com/apache/flink/pull/19556#discussion_r939864611


##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/planner/delegation/hive/HiveOperationExecutor.java:
##########
@@ -123,4 +133,64 @@ private TableResultInternal buildResultForShowVariable(List<String> results) {
                 .data(rows)
                 .build();
     }
+
+    private Optional<TableResultInternal> executeHiveLoadDataOperation(
+            HiveLoadDataOperation hiveLoadDataOperation) {
+        Catalog currentCatalog =
+                catalogManager.getCatalog(catalogManager.getCurrentCatalog()).orElse(null);
+        if (!(currentCatalog instanceof HiveCatalog)) {
+            throw new FlinkHiveException(
+                    "Only support 'LOAD DATA INPATH' when the current catalog is HiveCatalog ing Hive dialect.");

Review Comment:
   ```suggestion
                       "Only support 'LOAD DATA INPATH' when the current catalog is HiveCatalog in Hive dialect.");
   ```



##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV100.java:
##########
@@ -94,6 +96,11 @@
 /** Shim for Hive version 1.0.0. */
 public class HiveShimV100 implements HiveShim {
 
+    protected boolean holdDDLTime = false;
+    protected boolean isAcid = false;
+    protected boolean inheritTableSpecs = true;
+    protected boolean isSkewedStoreAsSubdir = false;

Review Comment:
   It seems we never change these variables. Shall we add `final` modifier for them?



##########
flink-connectors/flink-connector-hive/src/test/resources/explain/testLoadData.out:
##########
@@ -0,0 +1,8 @@
+== Abstract Syntax Tree ==
+LOAD DATA LOCAL INPATH '$filepath' OVERWRITE INTO TABLE default.p_table PARTITION (dateint=2022)
+
+== Optimized Physical Plan ==
+LOAD DATA LOCAL INPATH '$filepath' OVERWRITE INTO TABLE default.p_table PARTITION (dateint=2022)
+
+== Optimized Execution Plan ==
+LOAD DATA LOCAL INPATH '$filepath' OVERWRITE INTO TABLE default.p_table PARTITION (dateint=2022)

Review Comment:
   In Spark, the explain of load data still follows query explain format. So how about:
   
   ```
   LoadData(filepath=[$filepath], table=[default.p_table], overwrite=[true], local=[true])
   ```
   
   This looks more like a **plan**. 



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectQueryITCase.java:
##########
@@ -500,19 +503,14 @@ public void testScriptTransform() throws Exception {
         try {
             // test explain transform
             String actualPlan =
-                    (String)
-                            CollectionUtil.iteratorToList(
-                                            tableEnv.executeSql(
-                                                            "explain select transform(key, value)"
-                                                                    + " ROW FORMAT SERDE 'MySerDe'"
-                                                                    + " WITH SERDEPROPERTIES ('p1'='v1','p2'='v2')"
-                                                                    + " RECORDWRITER 'MyRecordWriter' "
-                                                                    + " using 'cat' as (cola int, value string)"
-                                                                    + " ROW FORMAT DELIMITED FIELDS TERMINATED BY ','"
-                                                                    + " RECORDREADER 'MyRecordReader' from src")
-                                                    .collect())
-                                    .get(0)
-                                    .getField(0);
+                    explainSql(

Review Comment:
   Is there any reason for this change?



##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/planner/delegation/hive/HiveSessionState.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.delegation.hive;
+
+import org.apache.flink.connectors.hive.FlinkHiveException;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.hive.util.HiveReflectionUtils;
+import org.apache.flink.util.FileUtils;
+
+import org.apache.hadoop.hive.common.JavaUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.lockmgr.LockException;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Timestamp;
+import java.time.Instant;
+
+/** Sub-class of SessionState to meet our needs. */
+public class HiveSessionState extends SessionState {
+
+    private static final Logger LOG = LoggerFactory.getLogger(HiveSessionState.class);
+
+    private static final Method setCurrentTSMethod =
+            HiveReflectionUtils.tryGetMethod(
+                    SessionState.class, "setupQueryCurrentTimestamp", new Class[0]);
+    private static final Method getCurrentTSMethod =
+            HiveReflectionUtils.tryGetMethod(
+                    SessionState.class, "getQueryCurrentTimestamp", new Class[0]);
+
+    private static final Class registryClz;
+    private static final Method getRegistry;
+    private static final Method clearRegistry;
+    private static final Method closeRegistryLoaders;
+
+    private Timestamp hiveParserCurrentTS;
+
+    static {
+        registryClz = HiveReflectionUtils.tryGetClass("org.apache.hadoop.hive.ql.exec.Registry");

Review Comment:
   Do we have to use reflection here? Should they be in HiveShim? 



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] luoyuxia commented on pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
luoyuxia commented on PR #19556:
URL: https://github.com/apache/flink/pull/19556#issuecomment-1108000930

   @flinkbot run azure


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] wuchong merged pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
wuchong merged PR #19556:
URL: https://github.com/apache/flink/pull/19556


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] luoyuxia commented on pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
luoyuxia commented on PR #19556:
URL: https://github.com/apache/flink/pull/19556#issuecomment-1201923571

   @flinkbot run azure


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] luoyuxia commented on a diff in pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
luoyuxia commented on code in PR #19556:
URL: https://github.com/apache/flink/pull/19556#discussion_r940469589


##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectQueryITCase.java:
##########
@@ -500,19 +503,14 @@ public void testScriptTransform() throws Exception {
         try {
             // test explain transform
             String actualPlan =
-                    (String)
-                            CollectionUtil.iteratorToList(
-                                            tableEnv.executeSql(
-                                                            "explain select transform(key, value)"
-                                                                    + " ROW FORMAT SERDE 'MySerDe'"
-                                                                    + " WITH SERDEPROPERTIES ('p1'='v1','p2'='v2')"
-                                                                    + " RECORDWRITER 'MyRecordWriter' "
-                                                                    + " using 'cat' as (cola int, value string)"
-                                                                    + " ROW FORMAT DELIMITED FIELDS TERMINATED BY ','"
-                                                                    + " RECORDREADER 'MyRecordReader' from src")
-                                                    .collect())
-                                    .get(0)
-                                    .getField(0);
+                    explainSql(

Review Comment:
   No any special reason.
   When working in this pr, I found there're some tests have the explain sql logic, so I extact the logic to a explain method, and then make other tests to call this method.



##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/planner/delegation/hive/HiveSessionState.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.delegation.hive;
+
+import org.apache.flink.connectors.hive.FlinkHiveException;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.hive.util.HiveReflectionUtils;
+import org.apache.flink.util.FileUtils;
+
+import org.apache.hadoop.hive.common.JavaUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.lockmgr.LockException;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.Timestamp;
+import java.time.Instant;
+
+/** Sub-class of SessionState to meet our needs. */
+public class HiveSessionState extends SessionState {
+
+    private static final Logger LOG = LoggerFactory.getLogger(HiveSessionState.class);
+
+    private static final Method setCurrentTSMethod =
+            HiveReflectionUtils.tryGetMethod(
+                    SessionState.class, "setupQueryCurrentTimestamp", new Class[0]);
+    private static final Method getCurrentTSMethod =
+            HiveReflectionUtils.tryGetMethod(
+                    SessionState.class, "getQueryCurrentTimestamp", new Class[0]);
+
+    private static final Class registryClz;
+    private static final Method getRegistry;
+    private static final Method clearRegistry;
+    private static final Method closeRegistryLoaders;
+
+    private Timestamp hiveParserCurrentTS;
+
+    static {
+        registryClz = HiveReflectionUtils.tryGetClass("org.apache.hadoop.hive.ql.exec.Registry");

Review Comment:
   Actually, I'm not sure why use reflection here.
   I guess it's for compatibility for lower version hive like 1.1.0 since the class `Registry ` is introduced in [Hive 1.2.0](https://issues.apache.org/jira/browse/HIVE-2573). Although we only provide flink-sql-hive-connector 2.3.x and 3.1.x currenly, user may pack with other lower version hive-exec, so I think it'll be better not to change it.
   I think it's not necessary to put it in HiveShim.
   



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] luoyuxia commented on pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
luoyuxia commented on PR #19556:
URL: https://github.com/apache/flink/pull/19556#issuecomment-1208778544

   @flinkbot run azure


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #19556: [FLINK-26413][hive] Hive dialect supports "LOAD DATA INPATH"

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #19556:
URL: https://github.com/apache/flink/pull/19556#issuecomment-1106473307

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "4d99ef8a1ea72740067fb5838d9c854a622be5d5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "4d99ef8a1ea72740067fb5838d9c854a622be5d5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 4d99ef8a1ea72740067fb5838d9c854a622be5d5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org