Search in sources :

Example 26 with DataSourceOptions

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

the class TileDBDataSourceOptionsTest method testArrayURIOptionMissing.

@Test
public void testArrayURIOptionMissing() throws Exception {
    DataSourceOptions dsOptions = new DataSourceOptions(new HashMap<>());
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(dsOptions);
    Assert.assertFalse(options.getArrayURI().isPresent());
}
Also used : DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 27 with DataSourceOptions

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

the class TileDBDataSourceOptionsTest method testValidArrayLayoutOptions.

@Test
public void testValidArrayLayoutOptions() throws Exception {
    String[] validLayoutStrings = new String[] { "row-major", "TILEDB_ROW_MAJOR", "col-major", "TILEDB_COL_MAJOR", "unordered", "TILEDB_UNORDERED" };
    Layout[] expectedLayouts = new Layout[] { Layout.TILEDB_ROW_MAJOR, Layout.TILEDB_ROW_MAJOR, Layout.TILEDB_COL_MAJOR, Layout.TILEDB_COL_MAJOR, Layout.TILEDB_UNORDERED, Layout.TILEDB_UNORDERED };
    for (int i = 0; i < validLayoutStrings.length; i++) {
        HashMap<String, String> optionMap = new HashMap<>();
        optionMap.put("order", validLayoutStrings[i]);
        TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
        Optional<Layout> layout = options.getArrayLayout();
        Assert.assertTrue(layout.isPresent());
        Assert.assertEquals(expectedLayouts[i], layout.get());
    }
}
Also used : Layout(io.tiledb.java.api.Layout) HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 28 with DataSourceOptions

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

the class TileDBDataSourceOptionsTest method testTileDBConfigOption.

@Test
public void testTileDBConfigOption() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    optionMap.put("uri", "s3://foo/bar");
    optionMap.put("tiledb.sm.dedup_coords", "true");
    optionMap.put("tiledb.sm.check_coord_dups", "false");
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Map<String, String> tiledbOptions = options.getTileDBConfigMap(true);
    Assert.assertEquals("false", tiledbOptions.get("sm.check_coord_dups"));
    Assert.assertEquals("true", tiledbOptions.get("sm.dedup_coords"));
}
Also used : HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 29 with DataSourceOptions

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

the class TileDBDataSourceOptionsTest method testEmptyTileDBConfigOption.

@Test
public void testEmptyTileDBConfigOption() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    optionMap.put("uri", "s3://foo/bar");
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Assert.assertTrue(options.getTileDBConfigMap(true).size() == // 3 parameters for var attributes on arrowBuffs
    3);
}
Also used : HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) Test(org.junit.Test)

Example 30 with DataSourceOptions

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

the class TileDBDataSourceOptionsTest method testArrayURIOption.

@Test
public void testArrayURIOption() throws Exception {
    HashMap<String, String> optionMap = new HashMap<>();
    optionMap.put("uri", "s3://foo/bar");
    TileDBDataSourceOptions options = new TileDBDataSourceOptions(new DataSourceOptions(optionMap));
    Optional<URI> uri = options.getArrayURI();
    Assert.assertTrue(uri.isPresent());
    Assert.assertEquals(URI.create("s3://foo/bar"), uri.get());
}
Also used : HashMap(java.util.HashMap) DataSourceOptions(org.apache.spark.sql.sources.v2.DataSourceOptions) URI(java.net.URI) 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