drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppadma <...@git.apache.org>
Subject [GitHub] drill pull request #789: DRILL-5356: Refactor Parquet Record Reader
Date Wed, 29 Mar 2017 15:03:39 GMT
Github user ppadma commented on a diff in the pull request:

    https://github.com/apache/drill/pull/789#discussion_r108667588
  
    --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/ParquetInternalsTest.java
---
    @@ -0,0 +1,154 @@
    +/*
    + * 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.exec.store.parquet;
    +
    +import static org.junit.Assert.*;
    +
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +import org.apache.drill.TestBuilder;
    +import org.apache.drill.common.expression.SchemaPath;
    +import org.apache.drill.common.types.TypeProtos;
    +import org.apache.drill.common.types.Types;
    +import org.apache.drill.test.ClusterFixture;
    +import org.apache.drill.test.ClusterTest;
    +import org.apache.drill.test.FixtureBuilder;
    +import org.junit.BeforeClass;
    +import org.junit.Test;
    +
    +public class ParquetInternalsTest extends ClusterTest {
    +
    +  @BeforeClass
    +  public static void setup( ) throws Exception {
    +    FixtureBuilder builder = ClusterFixture.builder()
    +      // Set options, etc.
    +      ;
    +    startCluster(builder);
    +  }
    +
    +  @Test
    +  public void testFixedWidth() throws Exception {
    +    String sql = "SELECT l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity\n"
+
    +                 "FROM `cp`.`tpch/lineitem.parquet` LIMIT 20";
    +//    client.queryBuilder().sql(sql).printCsv();
    +
    +    Map<SchemaPath, TypeProtos.MajorType> typeMap = new HashMap<>();
    +    typeMap.put(TestBuilder.parsePath("l_orderkey"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("l_partkey"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("l_suppkey"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("l_linenumber"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("l_quantity"), Types.required(TypeProtos.MinorType.FLOAT8));
    +    client.testBuilder()
    +      .sqlQuery(sql)
    +      .unOrdered()
    +      .csvBaselineFile("parquet/expected/fixedWidth.csv")
    +      .baselineColumns("l_orderkey", "l_partkey", "l_suppkey", "l_linenumber", "l_quantity")
    +      .baselineTypes(typeMap)
    +      .build()
    +      .run();
    +  }
    +
    +
    +  @Test
    +  public void testVariableWidth() throws Exception {
    +    String sql = "SELECT s_name, s_address, s_phone, s_comment\n" +
    +                 "FROM `cp`.`tpch/supplier.parquet` LIMIT 20";
    +    client.queryBuilder().sql(sql).printCsv();
    +
    +    Map<SchemaPath, TypeProtos.MajorType> typeMap = new HashMap<>();
    +    typeMap.put(TestBuilder.parsePath("s_name"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_address"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_phone"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_comment"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    client.testBuilder()
    +      .sqlQuery(sql)
    +      .unOrdered()
    +      .csvBaselineFile("parquet/expected/variableWidth.csv")
    +      .baselineColumns("s_name", "s_address", "s_phone", "s_comment")
    +      .baselineTypes(typeMap)
    +      .build()
    +      .run();
    +  }
    +
    +  @Test
    +  public void testMixedWidth() throws Exception {
    +    String sql = "SELECT s_suppkey, s_name, s_address, s_phone, s_acctbal\n" +
    +                 "FROM `cp`.`tpch/supplier.parquet` LIMIT 20";
    +//    client.queryBuilder().sql(sql).printCsv();
    +
    +    Map<SchemaPath, TypeProtos.MajorType> typeMap = new HashMap<>();
    +    typeMap.put(TestBuilder.parsePath("s_suppkey"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("s_name"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_address"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_phone"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_acctbal"), Types.required(TypeProtos.MinorType.FLOAT8));
    +    client.testBuilder()
    +      .sqlQuery(sql)
    +      .unOrdered()
    +      .csvBaselineFile("parquet/expected/mixedWidth.csv")
    +      .baselineColumns("s_suppkey", "s_name", "s_address", "s_phone", "s_acctbal")
    +      .baselineTypes(typeMap)
    +      .build()
    +      .run();
    +  }
    +
    +  @Test
    +  public void testStar() throws Exception {
    +    String sql = "SELECT *\n" +
    +                 "FROM `cp`.`tpch/supplier.parquet` LIMIT 20";
    +//    client.queryBuilder().sql(sql).printCsv();
    +
    +    Map<SchemaPath, TypeProtos.MajorType> typeMap = new HashMap<>();
    +    typeMap.put(TestBuilder.parsePath("s_suppkey"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("s_name"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_address"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_nationkey"), Types.required(TypeProtos.MinorType.INT));
    +    typeMap.put(TestBuilder.parsePath("s_phone"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    typeMap.put(TestBuilder.parsePath("s_acctbal"), Types.required(TypeProtos.MinorType.FLOAT8));
    +    typeMap.put(TestBuilder.parsePath("s_comment"), Types.required(TypeProtos.MinorType.VARCHAR));
    +    client.testBuilder()
    +      .sqlQuery(sql)
    +      .unOrdered()
    +      .csvBaselineFile("parquet/expected/star.csv")
    +      .baselineColumns("s_suppkey", "s_name", "s_address", "s_nationkey", "s_phone",
"s_acctbal", "s_comment")
    +      .baselineTypes(typeMap)
    +      .build()
    +      .run();
    +  }
    +
    +  @Test
    +  public void testMissing() throws Exception {
    +    String sql = "SELECT s_suppkey, bogus\n" +
    +                 "FROM `cp`.`tpch/supplier.parquet` LIMIT 20";
    +    client.queryBuilder().sql(sql).printCsv();
    --- End diff --
    
    Do you want to comment this line  ? This test is not doing anything. If we plan to fix
it later, add comments accordingly. 


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