RussellSpitzer commented on a change in pull request #3723: URL: https://github.com/apache/iceberg/pull/3723#discussion_r771522012
########## File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/data/TestParquetReader.java ########## @@ -0,0 +1,157 @@ +/* + * 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.iceberg.spark.data; + +import java.io.File; +import java.util.List; +import java.util.Map; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.apache.iceberg.spark.SparkSessionCatalog; +import org.apache.iceberg.spark.SparkTestBaseWithCatalog; +import org.apache.iceberg.spark.actions.SparkActions; +import org.apache.spark.sql.SparkSession; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +public class TestParquetReader extends SparkTestBaseWithCatalog { + private static SparkSession spark = null; + private static String catalogName = "spark_catalog"; + private static String implementation = SparkSessionCatalog.class.getName(); + private static Map<String, String> config = ImmutableMap.of( + "type", "hive", + "default-namespace", "default", + "parquet-enabled", "true", + "cache-enabled", "false" + ); + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + public TestParquetReader() { + super(catalogName, implementation, config); + spark.sessionState().catalogManager().catalog(catalogName); + } + + @BeforeClass + public static void startSpark() { + TestParquetReader.spark = SparkSession.builder().master("local[2]") + .config("spark.sql.parquet.writeLegacyFormat", true) + .getOrCreate(); + spark.sessionState().catalogManager().catalog("spark_catalog"); + } + + @AfterClass + public static void stopSpark() { + SparkSession currentSpark = TestParquetReader.spark; + TestParquetReader.spark = null; + currentSpark.stop(); + } + + @Test + public void testHiveStyleThreeLevelList1() throws Exception { + String tableName = "default.testHiveStyleThreeLevelList"; + File location = temp.newFolder(); + sql(String.format("CREATE TABLE %s (col1 ARRAY<STRUCT<col2 INT>>)" + + " STORED AS parquet" + + " LOCATION '%s'", tableName, location)); + + int testValue = 12345; + sql(String.format("INSERT INTO %s VALUES (ARRAY(STRUCT(%s)))", tableName, testValue)); Review comment: our "sql" method doesn't require a format, it uses the first arg as a format string It's essentially ``` sql( format, args*) { return spark.sql(String.format(format, args)) }``` ########## File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/data/TestParquetReader.java ########## @@ -0,0 +1,157 @@ +/* + * 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.iceberg.spark.data; + +import java.io.File; +import java.util.List; +import java.util.Map; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.apache.iceberg.spark.SparkSessionCatalog; +import org.apache.iceberg.spark.SparkTestBaseWithCatalog; +import org.apache.iceberg.spark.actions.SparkActions; +import org.apache.spark.sql.SparkSession; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +public class TestParquetReader extends SparkTestBaseWithCatalog { + private static SparkSession spark = null; + private static String catalogName = "spark_catalog"; + private static String implementation = SparkSessionCatalog.class.getName(); + private static Map<String, String> config = ImmutableMap.of( + "type", "hive", + "default-namespace", "default", + "parquet-enabled", "true", + "cache-enabled", "false" + ); + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + public TestParquetReader() { + super(catalogName, implementation, config); + spark.sessionState().catalogManager().catalog(catalogName); + } + + @BeforeClass + public static void startSpark() { + TestParquetReader.spark = SparkSession.builder().master("local[2]") + .config("spark.sql.parquet.writeLegacyFormat", true) + .getOrCreate(); + spark.sessionState().catalogManager().catalog("spark_catalog"); + } + + @AfterClass + public static void stopSpark() { + SparkSession currentSpark = TestParquetReader.spark; + TestParquetReader.spark = null; + currentSpark.stop(); + } + + @Test + public void testHiveStyleThreeLevelList1() throws Exception { + String tableName = "default.testHiveStyleThreeLevelList"; + File location = temp.newFolder(); + sql(String.format("CREATE TABLE %s (col1 ARRAY<STRUCT<col2 INT>>)" + + " STORED AS parquet" + + " LOCATION '%s'", tableName, location)); + + int testValue = 12345; + sql(String.format("INSERT INTO %s VALUES (ARRAY(STRUCT(%s)))", tableName, testValue)); Review comment: our "sql" method doesn't require a format, it uses the first arg as a format string It's essentially ``` sql( format, args*) { return spark.sql(String.format(format, args)) } ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
