Skip to content

Commit

Permalink
Add tests for table formats and special chars in location
Browse files Browse the repository at this point in the history
This is testing native filesystem implementation
  • Loading branch information
anusudarsan committed May 22, 2024
1 parent 0276d1c commit e39e770
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<value>false</value>
</property>

<property>
<name>fs.gs.path.encoding</name>
<value>uri-path</value>
</property>

<!-- Google Cloud Storage properties -->
<property>
<name>fs.gs.impl</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
*/
package io.trino.tests.product;

import com.google.common.collect.ImmutableList;
import io.trino.tempto.ProductTest;
import io.trino.tempto.assertions.QueryAssert;

import java.util.List;

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.testing.TestingNames.randomNameSuffix;
Expand Down Expand Up @@ -77,4 +81,50 @@ protected void testCreateAndInsertTable(String schemaLocation)
onTrino().executeQuery("DROP SCHEMA %1$s.test".formatted(getCatalogName()));
}
}

protected void testPathContainsSpecialCharacter(String schemaLocation, String partitioningPropertyName)
{
String tableName = "test_path_special_character" + randomNameSuffix();
try {
onTrino().executeQuery(format("CREATE SCHEMA %1$s.test WITH (location = '%2$s')", getCatalogName(), schemaLocation));
onTrino().executeQuery(format(
"CREATE TABLE %1$s.test.%2$s (id bigint, part varchar) WITH (%3$s = ARRAY['part'])",
getCatalogName(),
tableName,
partitioningPropertyName));

onTrino().executeQuery("INSERT INTO " + getCatalogName() + ".test." + tableName + " VALUES " +
"(1, 'with-hyphen')," +
"(2, 'with.dot')," +
"(3, 'with:colon')," +
"(4, 'with/slash')," +
"(5, 'with\\\\backslashes')," +
"(6, 'with\\backslash')," +
"(7, 'with=equal')," +
"(8, 'with?question')," +
"(9, 'with!exclamation')," +
"(10, 'with%percent')," +
"(11, 'with%%percents')," +
"(12, 'with space')");

List<QueryAssert.Row> expectedRows = ImmutableList.of(
row(1, "with-hyphen"),
row(2, "with.dot"),
row(3, "with:colon"),
row(4, "with/slash"),
row(5, "with\\\\backslashes"),
row(6, "with\\backslash"),
row(7, "with=equal"),
row(8, "with?question"),
row(9, "with!exclamation"),
row(10, "with%percent"),
row(11, "with%%percents"),
row(12, "with space"));
assertThat(onTrino().executeQuery(format("SELECT * FROM %1$s.test.%2$s", getCatalogName(), tableName))).containsOnly(expectedRows);
}
finally {
onTrino().executeQuery("DROP TABLE %1$s.test.%2$s".formatted(getCatalogName(), tableName));
onTrino().executeQuery("DROP SCHEMA %1$s.test".formatted(getCatalogName()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ public void testBasicWriteOperations()
{
super.testBasicWriteOperations(schemaLocation);
}

@Test(groups = {DELTA_LAKE_AZURE, PROFILE_SPECIFIC_TESTS})
public void testPathContainsSpecialCharacter()
{
super.testPathContainsSpecialCharacter(schemaLocation, "partitioned_by");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public void testBasicWriteOperations()
super.testBasicWriteOperations(warehouseDirectory);
}

@Test(groups = {DELTA_LAKE_GCS, PROFILE_SPECIFIC_TESTS})
public void testPathContainsSpecialCharacter()
{
super.testPathContainsSpecialCharacter(warehouseDirectory, "partitioned_by");
}

@Override
protected String getCatalogName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ public void testInsertTable()
{
super.testCreateAndInsertTable(schemaLocation);
}

@Test(groups = {AZURE, PROFILE_SPECIFIC_TESTS})
public void testPathContainsSpecialCharacter()
{
super.testPathContainsSpecialCharacter(schemaLocation, "partitioned_by");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public void testInsertTable()
super.testCreateAndInsertTable(warehouseDirectory);
}

@Test(groups = {HIVE_GCS, PROFILE_SPECIFIC_TESTS})
public void testPathContainsSpecialCharacter()
{
super.testPathContainsSpecialCharacter(warehouseDirectory, "partitioned_by");
}

@Override
protected String getCatalogName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ public void testBasicWriteOperations()
{
super.testBasicWriteOperations(schemaLocation);
}

@Test(groups = {ICEBERG_AZURE, PROFILE_SPECIFIC_TESTS})
public void testPathContainsSpecialCharacter()
{
super.testPathContainsSpecialCharacter(schemaLocation, "partitioning");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public void testBasicWriteOperations()
super.testBasicWriteOperations(warehouseDirectory);
}

@Test(groups = {ICEBERG_GCS, PROFILE_SPECIFIC_TESTS})
public void testPathContainsSpecialCharacter()
{
super.testPathContainsSpecialCharacter(warehouseDirectory, "partitioning");
}

@Override
protected String getCatalogName()
{
Expand Down

0 comments on commit e39e770

Please sign in to comment.