zjuwangg commented on a change in pull request #8809: [FLIN-12663]Implement 
HiveTableSource to read Hive tables
URL: https://github.com/apache/flink/pull/8809#discussion_r296590433
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/batch/connectors/hive/HiveTableSourceTest.java
 ##########
 @@ -0,0 +1,123 @@
+/*
+ * 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.batch.connectors.hive;
+
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.DataSet;
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.api.java.typeutils.RowTypeInfo;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.table.api.java.BatchTableEnvironment;
+import org.apache.flink.table.catalog.hive.HiveCatalog;
+import org.apache.flink.table.catalog.hive.HiveTestUtils;
+import org.apache.flink.table.catalog.hive.client.HiveMetastoreClientFactory;
+import org.apache.flink.table.catalog.hive.client.HiveMetastoreClientWrapper;
+import org.apache.flink.table.catalog.hive.util.HiveTableUtil;
+import org.apache.flink.types.Row;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
+import org.apache.hadoop.mapred.JobConf;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Tests {@link HiveTableSource}
+ */
+public class HiveTableSourceTest {
+       public static final String DEFAULT_SERDE_CLASS = 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.class.getName();
+       public static final String DEFAULT_INPUT_FORMAT_CLASS = 
org.apache.hadoop.mapred.TextInputFormat.class.getName();
+       public static final String DEFAULT_OUTPUT_FORMAT_CLASS = 
org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat.class.getName();
+
+       private static HiveCatalog hiveCatalog;
+       private static HiveConf hiveConf;
+
+       @BeforeClass
+       public static void createCatalog() throws IOException {
+               hiveConf = HiveTestUtils.createHiveConf();
+               hiveCatalog = HiveTestUtils.createHiveCatalog(hiveConf);
+               hiveCatalog.open();
+       }
+
+       @AfterClass
+       public static void closeCatalog() {
+               if (null != hiveCatalog) {
+                       hiveCatalog.close();
+               }
+       }
+
+       @Test
+       public void testReadNonPartitionedTable() throws Exception {
+               final String dbName = "default";
+               final String tblName = "test";
+               TableSchema tableSchema = new TableSchema(
+                               new String[]{"a", "b", "c", "d", "e"},
+                               new TypeInformation[]{
+                                               BasicTypeInfo.INT_TYPE_INFO,
+                                               BasicTypeInfo.INT_TYPE_INFO,
+                                               BasicTypeInfo.STRING_TYPE_INFO,
+                                               BasicTypeInfo.LONG_TYPE_INFO,
+                                               BasicTypeInfo.DOUBLE_TYPE_INFO}
+               );
+               //Now we used metaStore client to create hive table instead of 
using hiveCatalog for it doesn't support set
+               //serDe temporarily.
+               HiveMetastoreClientWrapper client = 
HiveMetastoreClientFactory.create(hiveConf, null);
+               org.apache.hadoop.hive.metastore.api.Table tbl = new 
org.apache.hadoop.hive.metastore.api.Table();
 
 Review comment:
   It's conflicts with org.apache.flink.table.api.Table.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to