drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansinha100 <...@git.apache.org>
Subject [GitHub] drill pull request #514: DRILL-4694: CTAS in JSON format produces extraneous...
Date Sat, 04 Jun 2016 01:55:02 GMT
Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/514#discussion_r65795257
  
    --- Diff: exec/java-exec/src/test/java/org/apache/drill/TestCTASJson.java ---
    @@ -0,0 +1,129 @@
    +/**
    + * 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.drill;
    +
    +
    +import org.apache.drill.common.util.TestTools;
    +import org.apache.drill.exec.ExecConstants;
    +import org.junit.Test;
    +
    +import static org.junit.Assert.assertEquals;
    +
    +public class TestCTASJson extends PlanTestBase {
    +  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestCTASJson.class);
    +
    +  static final String WORKING_PATH = TestTools.getWorkingPath();
    +  static final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources";
    +
    +  @Test
    +  /**
    +   * Test a source json file that contains records that are maps with fields of all types.
    +   * Some records have missing fields. CTAS should skip the missing fields
    +   */ public void testctas_alltypes_map() throws Exception {
    +    String testName = "ctas_alltypes_map";
    +    test("use dfs_test.tmp");
    +    test("alter session set store.format = 'json' ");
    +    test("alter session set store.json.writer.skip_null_fields = true"); // DEFAULT
    +    test("create table " + testName + "_json as select * from cp.`json/" + testName +
".json`");
    +
    +    final String query = "select * from `" + testName + "_json` t1 ";
    +
    +    testBuilder()
    +        .sqlQuery(query)
    +        .ordered()
    +        .jsonBaselineFile("json/" + testName + ".json")
    +        .build()
    +        .run();
    +
    +    test("drop table " + testName + "_json" );
    +  }
    +
    +  @Test
    +  /**
    +   * Test a source json file that contains records that are maps with fields of all types.
    +   * Some records have missing fields. CTAS should NOT skip the missing fields
    +   */
    +  public void testctas_alltypes_map_noskip() throws Exception {
    +    String testName = "ctas_alltypes_map";
    +    test("use dfs_test.tmp");
    +    test("alter session set store.format = 'json' ");
    +    test("alter session set store.json.writer.skip_null_fields = false"); // CHANGE from
default
    +    test("create table " + testName + "_json as select * from cp.`json/" + testName +
".json`");
    +
    +    final String query = "select * from `" + testName + "_json` t1 ";
    +
    +    testBuilder()
    +        .sqlQuery(query)
    +        .ordered()
    +        .jsonBaselineFile("json/" + testName + "_out.json")
    +        .build()
    +        .run();
    +
    +    test("drop table " + testName + "_json" );
    +  }
    +
    +  @Test
    +  /**
    +   * Test a source json file that contains records that are maps with fields of all types.
    +   * Some records have missing fields. CTAS should skip the missing fields
    +   */ public void testctas_alltypes_repeatedmap() throws Exception {
    +    String testName = "ctas_alltypes_repeated_map";
    +    test("use dfs_test.tmp");
    +    test("alter session set store.format = 'json' ");
    +    test("alter session set store.json.writer.skip_null_fields = true"); // DEFAULT
    +    test("create table " + testName + "_json as select * from cp.`json/" + testName +
".json`");
    +
    +    final String query = "select * from `" + testName + "_json` t1 ";
    +
    +    testBuilder()
    +        .sqlQuery(query)
    +        .ordered()
    +        .jsonBaselineFile("json/" + testName + ".json")
    +        .build()
    +        .run();
    +
    +    test("drop table " + testName + "_json" );
    +
    +  }
    +
    +  @Test
    +  /**
    +   * Test a source json file that contains records that are maps with fields of all types.
    +   * Some records have missing fields. CTAS should NOT skip the missing fields
    +   */
    +  public void testctas_alltypes_repeated_map_noskip() throws Exception {
    +    String testName = "ctas_alltypes_repeated_map";
    +    test("use dfs_test.tmp");
    +    test("alter session set store.format = 'json' ");
    +    test("alter session set store.json.writer.skip_null_fields = false"); // CHANGE from
default
    --- End diff --
    
    The testBuilder provides the optionSettingQueriesForTestQuery() method to set the options
per query.  Would be good to use it and have a finally block {} that resets the option. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message