luoyuxia commented on code in PR #19520:
URL: https://github.com/apache/flink/pull/19520#discussion_r892240386
##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectQueryITCase.java:
##########
@@ -330,6 +333,59 @@ public void testJoinInvolvingComplexType() throws
Exception {
}
}
+ @Test
+ public void testInsertDirectory() throws Exception {
+ String warehouse =
hiveCatalog.getHiveConf().getVar(HiveConf.ConfVars.METASTOREWAREHOUSE);
+
+ // test insert overwrite directory with row format parameters
+ tableEnv.executeSql("create table map_table (foo STRING , bar
MAP<STRING, INT>)");
+ tableEnv.executeSql(
+ "insert into map_table select 'A',
map('math',100,'english',90,'history',85)");
+
+ String dataDir = warehouse + "/map_table_dir";
+ tableEnv.executeSql(
+ String.format(
+ "INSERT OVERWRITE DIRECTORY '%s'"
+ + "ROW FORMAT DELIMITED \n"
+ + "FIELDS TERMINATED BY ':'\n"
+ + "COLLECTION ITEMS TERMINATED BY '#'
\n"
+ + "MAP KEYS TERMINATED BY '=' select *
from map_table",
+ dataDir))
+ .await();
+ java.nio.file.Path[] files =
+ FileUtils.listFilesInDirectory(
+ Paths.get(dataDir), (path) ->
!path.toFile().isHidden())
+ .toArray(new Path[0]);
+ assertEquals(1, files.length);
+ String actualString = FileUtils.readFileUtf8(files[0].toFile());
Review Comment:
Here, we want to make sure the file format like `separator` is consistent
with specified in SQL.
If create a external table and then read it, we can't make such guarantee.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]