Search in sources :

Example 16 with DataSourceOptions

use of org.apache.spark.sql.sources.v2.DataSourceOptions in project TileDB-Spark by TileDB-Inc.

the class TileDBDataSourceOptionsTest method testTileDBSchemaDims.

@Test
public void testTileDBSchemaDims() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    optionMap.put("uri", "s3://foo/bar");
    optionMap.put("schema.dim.0.name", "rows");
    optionMap.put("schema.dim.1.name", "cols");
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Assert.assertTrue(options.getSchemaDimensionNames().isPresent());
    List<Pair<String, Integer>> schemaDims = options.getSchemaDimensionNames().get();
    Assert.assertEquals("rows", schemaDims.get(0).getFirst());
    Assert.assertEquals(Integer.valueOf(0), schemaDims.get(0).getSecond());
    Assert.assertEquals("cols", schemaDims.get(1).getFirst());
    Assert.assertEquals(Integer.valueOf(1), schemaDims.get(1).getSecond());
}
Also used : HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Pair(io.tiledb.java.api.Pair) Test(org.junit.Test)

Example 17 with DataSourceOptions

use of org.apache.spark.sql.sources.v2.DataSourceOptions in project TileDB-Spark by TileDB-Inc.

the class TileDBDataSourceOptionsTest method testInvalidLayoutOptions.

@Test(expected = IllegalArgumentException.class)
public void testInvalidLayoutOptions() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    optionMap.put("order", "bad-layout-option");
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Optional<Layout> layout = options.getArrayLayout();
}
Also used : HashMap(java.util.HashMap) Layout(io.tiledb.java.api.Layout) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 18 with DataSourceOptions

use of org.apache.spark.sql.sources.v2.DataSourceOptions in project TileDB-Spark by TileDB-Inc.

the class TileDBDataSourceOptionsTest method testEmptyDimensionPartitions.

@Test
public void testEmptyDimensionPartitions() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Optional<List<OptionDimPartition>> partitions = options.getDimPartitions();
    Assert.assertFalse(partitions.isPresent());
}
Also used : HashMap(java.util.HashMap) List(java.util.List) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 19 with DataSourceOptions

use of org.apache.spark.sql.sources.v2.DataSourceOptions in project TileDB-Spark by TileDB-Inc.

the class TileDBDataSourceOptionsTest method testNoArrayLayoutOption.

@Test
public void testNoArrayLayoutOption() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Assert.assertFalse(options.getArrayLayout().isPresent());
}
Also used : HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 20 with DataSourceOptions

use of org.apache.spark.sql.sources.v2.DataSourceOptions in project TileDB-Spark by TileDB-Inc.

the class TileDBDataSourceOptionsTest method testEmptyTileDBSchemaDims.

@Test
public void testEmptyTileDBSchemaDims() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    optionMap.put("uri", "s3://foo/bar");
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Assert.assertFalse(options.getSchemaDimensionNames().isPresent());
}
Also used : HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Aggregations

DataSourceOptions (org.apache.spark.sql.sources.v2.DataSourceOptions)38 Test (org.junit.Test)33 HashMap (java.util.HashMap)13 Configuration (org.apache.hadoop.conf.Configuration)13 SQLConf (org.apache.spark.sql.internal.SQLConf)10 ArrayList (java.util.ArrayList)4 HoodieWriteConfig (org.apache.hudi.config.HoodieWriteConfig)4 Row (org.apache.spark.sql.Row)4 InternalRow (org.apache.spark.sql.catalyst.InternalRow)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 List (java.util.List)3 DataSourceReader (org.apache.spark.sql.sources.v2.reader.DataSourceReader)3 Layout (io.tiledb.java.api.Layout)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 ObjectOutputStream (java.io.ObjectOutputStream)2 URI (java.net.URI)2 DataFile (org.apache.iceberg.DataFile)2 Table (org.apache.iceberg.Table)2