Github user chiwanpark commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1064#discussion_r38078462
  
    --- Diff: 
flink-staging/flink-hcatalog/src/test/scala/org/apache/flink/hcatalog/scala/test/HCatInputOutputFormatITest.scala
 ---
    @@ -0,0 +1,215 @@
    +/*
    + * 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.hcatalog.scala.test
    +
    +
    +import java.io.{FileWriter, FileReader, BufferedReader, IOException, File}
    +
    +import org.apache.commons.io.FileUtils
    +import org.apache.flink.api.scala.{DataSet, ExecutionEnvironment, _}
    +import org.apache.flink.hcatalog.scala.{HCatInputFormat, HCatOutputFormat}
    +import org.apache.hadoop.hive.cli.CliSessionState
    +import org.apache.hadoop.hive.conf.HiveConf
    +import org.apache.hadoop.hive.ql.Driver
    +import org.apache.hadoop.hive.ql.session.SessionState
    +import org.junit.Assert._
    +import org.junit.{After, Before, Test}
    +
    +class HCatInputOutputFormatITest {
    +  private var dataDir: File = null
    +  private var warehouseDir: String = null
    +  private var inputFileName: String = null
    +  private var driver: Driver = null
    +  private var input: Array[String] = null
    +  private var hiveConf: HiveConf = null
    +
    +  @Before
    +  @throws(classOf[Exception])
    +  def setup {
    +    dataDir = new File(System.getProperty("java.io.tmpdir") + 
File.separator +
    +      this.getClass.getCanonicalName + "-" + System.currentTimeMillis)
    +    hiveConf = new HiveConf
    +    warehouseDir = makePathASafeFileName(dataDir + File.separator + 
"warehouse")
    +    hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "")
    +    hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "")
    +    hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, 
"false")
    +    hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, 
warehouseDir)
    +    driver = new Driver(hiveConf)
    +    SessionState.start(new CliSessionState(hiveConf))
    +    if (!(new File(warehouseDir).mkdirs)) {
    +      throw new RuntimeException("Could not create " + warehouseDir)
    +    }
    +  }
    +
    +  @After
    +  @throws(classOf[IOException])
    +  def teardown {
    +    if (dataDir != null) {
    +      FileUtils.deleteDirectory(dataDir)
    +    }
    +  }
    +
    +  @Test
    +  @throws(classOf[Exception])
    +  def testReadTextFile {
    +    inputFileName = makePathASafeFileName(dataDir + File.separator + 
"input1.data")
    +
    +    input = Array[String]("a1/b1/c1\t1:v11/2:v12\td/1\te1\t0.1",
    +      "a2/b2/c2\t1:v21/2:v22\td/2\te2\t0.2")
    +
    +    createTestDataFile(inputFileName, input)
    +
    +    val createTable: String = "CREATE TABLE test_table(" +
    +      "c1 array<string>,\n" +
    +      "c2 map<int,string>,\n" +
    +      "c3 struct<name:string,score:int>,\n" +
    +      "c4 string,\n" +
    +      "c5 float)\n" +
    +      "row format delimited " +
    +      "fields terminated by '\t' " +
    +      "COLLECTION ITEMS TERMINATED BY '/' " +
    +      "MAP KEYS TERMINATED BY ':' " +
    +      "STORED AS TEXTFILE"
    +    driver.run("drop table test_table")
    +    val retCode1: Int = driver.run(createTable).getResponseCode
    +    assertTrue(retCode1 == 0)
    --- End diff --
    
    It would be helpful to add detail message such as "Failed to create table".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to