Skip to content

Commit

Permalink
Follow specification
Browse files Browse the repository at this point in the history
  • Loading branch information
leaves12138 committed Jan 8, 2025
1 parent 2bdfa4b commit d2fd4dc
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.stream.IntStream;

import static java.lang.String.format;

/**
* Trino {@link ConnectorMergeSink}.
*/
Expand All @@ -47,7 +49,7 @@ public void storeMergedRows(Page page)
int inputChannelCount = page.getChannelCount();
if (inputChannelCount != dataColumnCount + 2) {
throw new IllegalArgumentException(
String.format(
format(
"inputPage channelCount (%s) == dataColumns size (%s) + 2",
inputChannelCount, dataColumnCount));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import static java.lang.String.format;

/**
* Trino {@link ConnectorTableHandle}.
*/
Expand Down Expand Up @@ -186,7 +188,7 @@ public PaimonColumnHandle columnHandle(
int index = lowerCaseFieldNames.indexOf(field);
if (index == -1) {
throw new RuntimeException(
String.format("Cannot find field %s in schema %s", field, lowerCaseFieldNames));
format("Cannot find field %s in schema %s", field, lowerCaseFieldNames));
}
DataField dataField = paimonTable.rowType().getFields().get(index);
return PaimonColumnHandle.of(originFieldNames.get(index), dataField.type(), dataField.id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/**
* The query runner of trino.
*/
public class PaimonQueryRunner
final class PaimonQueryRunner
{
private static final Logger LOG = Logger.get(PaimonQueryRunner.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
* presto test util.
*/
public class PaimonTestUtils
final class PaimonTestUtils
{
private PaimonTestUtils() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* A simple table test helper to write and commit.
*/
public class SimpleTableTestHelper
final class SimpleTableTestHelper
{
private final InnerTableWrite writer;
private final InnerTableCommit commit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
/**
* Test for {@link PaimonColumnHandle}.
*/
public class PaimonColumnHandleTest
final class TestPaimonColumnHandle
{
@Test
public void testTrinoColumnHandle()
void testTrinoColumnHandle()
{
PaimonColumnHandle expected = PaimonColumnHandle.of("name", DataTypes.STRING(), 0);
testRoundTrip(expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
/**
* Test for {@link PaimonConnectorFactory}.
*/
public class PaimonConnectorFactoryTest
final class TestPaimonConnectorFactory
{
@TempDir java.nio.file.Path tempFile;

@Test
public void testCreateConnector()
void testCreateConnector()
{
Map<String, String> config = ImmutableMap.of("warehouse", tempFile.toString());
ConnectorFactory factory = new PaimonConnectorFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* The test of TrinoDistributedQuery.
*/
public class PaimonDistributedQueryTest
final class TestPaimonDistributedQuery
extends AbstractDistributedEngineOnlyQueries
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/**
* Test for {@link PaimonFilterConverter}.
*/
public class PaimonFilterConverterTest
public class TestPaimonFilterConverter
{
@Test
public void testAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
/**
* The test of TestTrinoFilterExtractor.
*/
public class PaimonFilterExtractorTest
final class TestPaimonFilterExtractor
{
@Test
public void testExtractTrinoColumnHandleForExpressionFilter()
void testExtractTrinoColumnHandleForExpressionFilter()
{
TupleDomain<ColumnHandle> summary = TupleDomain.all();
Type mapType = TESTING_TYPE_MANAGER.fromSqlType("map<varchar,varchar>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
/**
* ITCase for trino connector.
*/
public class PaimonITCase
final class TestPaimonITCase
extends AbstractTestQueryFramework
{
private static final String CATALOG = "paimon";
private static final String DB = "default";

protected long t2FirstCommitTimestamp;
private long t2FirstCommitTimestamp;

private static SimpleTableTestHelper createTestHelper(Path tablePath)
throws Exception
Expand All @@ -88,7 +88,7 @@ private static SimpleTableTestHelper createTestHelper(Path tablePath)
return new SimpleTableTestHelper(tablePath, rowType);
}

protected static String timestampLiteral(long epochMilliSeconds, int precision)
private static String timestampLiteral(long epochMilliSeconds, int precision)
{
return DateTimeFormatter.ofPattern(
"''yyyy-MM-dd HH:mm:ss." + "S".repeat(precision) + " VV''")
Expand Down Expand Up @@ -623,20 +623,20 @@ protected QueryRunner createQueryRunner()
}

@Test
public void testComplexTypes()
void testComplexTypes()
{
assertThat(sql("SELECT * FROM paimon.default.t4"))
.isEqualTo("[[1, {1=2}, [2, male], [1, 2, 3]]]");
}

@Test
public void testEmptyTable()
void testEmptyTable()
{
assertThat(sql("SELECT * FROM paimon.default.empty_t")).isEqualTo("[]");
}

@Test
public void testProjection()
void testProjection()
{
assertThat(sql("SELECT * FROM paimon.default.t1"))
.isEqualTo("[[1, 2, 1, 1], [5, 6, 3, 3]]");
Expand All @@ -645,15 +645,15 @@ public void testProjection()
}

@Test
public void testLimit()
void testLimit()
{
assertThat(sql("SELECT * FROM paimon.default.t1 LIMIT 1")).isEqualTo("[[1, 2, 1, 1]]");
assertThat(sql("SELECT * FROM paimon.default.t1 WHERE a = 5 LIMIT 1"))
.isEqualTo("[[5, 6, 3, 3]]");
}

@Test
public void testSystemTable()
void testSystemTable()
{
assertThat(
sql(
Expand All @@ -662,14 +662,14 @@ public void testSystemTable()
}

@Test
public void testFilter()
void testFilter()
{
assertThat(sql("SELECT a, aCa FROM paimon.default.t2 WHERE a < 4"))
.isEqualTo("[[1, 1], [3, 2]]");
}

@Test
public void testGroupByWithCast()
void testGroupByWithCast()
{
assertThat(
sql(
Expand All @@ -678,7 +678,7 @@ public void testGroupByWithCast()
}

@Test
public void testLimitWithPartition()
void testLimitWithPartition()
{
assertThat(sql("SELECT * FROM paimon.default.t3 WHERE pt = '1' LIMIT 1"))
.isEqualTo("[[1, 1, 1, 1, 1]]");
Expand All @@ -688,7 +688,7 @@ public void testLimitWithPartition()
}

@Test
public void testShowCreateTable()
void testShowCreateTable()
{
assertThat(sql("SHOW CREATE TABLE paimon.default.t3"))
.isEqualTo(
Expand All @@ -702,7 +702,7 @@ public void testShowCreateTable()
}

@Test
public void testCreateSchema()
void testCreateSchema()
{
sql("CREATE SCHEMA paimon.test");
assertThat(sql("SHOW SCHEMAS FROM paimon"))
Expand All @@ -711,15 +711,15 @@ public void testCreateSchema()
}

@Test
public void testDropSchema()
void testDropSchema()
{
sql("CREATE SCHEMA paimon.tpch");
sql("DROP SCHEMA paimon.tpch");
assertThat(sql("SHOW SCHEMAS FROM paimon")).isEqualTo("[[default], [information_schema]]");
}

@Test
public void testCreateTable()
void testCreateTable()
{
sql(
"CREATE TABLE orders ("
Expand All @@ -741,7 +741,7 @@ public void testCreateTable()
}

@Test
public void testRenameTable()
void testRenameTable()
{
sql(
"CREATE TABLE testRenameTable ("
Expand All @@ -767,7 +767,7 @@ public void testRenameTable()
}

@Test
public void testDropTable()
void testDropTable()
{
sql(
"CREATE TABLE testDropTable ("
Expand All @@ -790,7 +790,7 @@ public void testDropTable()
}

@Test
public void testAddColumn()
void testAddColumn()
{
sql(
"CREATE TABLE testAddColumn ("
Expand All @@ -815,7 +815,7 @@ public void testAddColumn()
}

@Test
public void testRenameColumn()
void testRenameColumn()
{
sql(
"CREATE TABLE testRenameColumn ("
Expand All @@ -840,7 +840,7 @@ public void testRenameColumn()
}

@Test
public void testDropColumn()
void testDropColumn()
{
sql(
"CREATE TABLE testDropColumn ("
Expand All @@ -865,7 +865,7 @@ public void testDropColumn()
}

@Test
public void testSetTableProperties()
void testSetTableProperties()
{
sql(
"CREATE TABLE testSetTableProperties ("
Expand All @@ -888,7 +888,7 @@ public void testSetTableProperties()
}

@Test
public void testAllType()
void testAllType()
{
assertThat(
sql(
Expand All @@ -901,7 +901,7 @@ public void testAllType()
}

@Test
public void testTimeTravel()
void testTimeTravel()
{
assertThat(sql("SELECT * FROM paimon.default.t2 FOR VERSION AS OF 1"))
.isEqualTo("[[1, 2, 1, 1], [3, 4, 2, 2]]");
Expand All @@ -921,7 +921,7 @@ public void testTimeTravel()
}

@Test
public void testTimeTravelWithTag()
void testTimeTravelWithTag()
{
// tag or snapshotId is string
assertThat(sql("SELECT * FROM paimon.default.t2 FOR VERSION AS OF '1'"))
Expand All @@ -934,7 +934,7 @@ public void testTimeTravelWithTag()
}

@Test
public void testSchemaEvolution()
void testSchemaEvolution()
{
assertThat(
sql(
Expand All @@ -948,21 +948,21 @@ public void testSchemaEvolution()
}

@Test
public void testDeletionFile()
void testDeletionFile()
{
assertThat(sql("SELECT * FROM paimon.default.t101 WHERE b > 0"))
.isEqualTo(
"[[a1, 1, 1], [a2, 2, 2], [a3, 3, 3], [a4, 4, 4], [a5, 5, 5], [a6, 6, 6], [a7, 7, 7], [a8, 8, 8], [a9, 9, 9]]");
}

@Test
public void testFileIndex()
void testFileIndex()
{
assertThat(sql("SELECT * FROM paimon.default.t102 where c = 2")).isEqualTo("[[a2, 2, 2]]");
}

@Test
public void testInsertIntoFixedBucketTableWiPk()
void testInsertIntoFixedBucketTableWiPk()
{
sql(
"INSERT INTO paimon.default.fixed_bucket_table_wi_pk VALUES (1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'),(6,'6')");
Expand All @@ -971,7 +971,7 @@ public void testInsertIntoFixedBucketTableWiPk()
}

@Test
public void testInsertIntoFixedBucketTableWoPk()
void testInsertIntoFixedBucketTableWoPk()
{
sql(
"INSERT INTO paimon.default.fixed_bucket_table_wo_pk VALUES (1,'1'),(2,'2'),(3,'3'),(4,'4'),(1,'1'),(2,'2'),(3,'3'),(4,'4')");
Expand All @@ -980,15 +980,15 @@ public void testInsertIntoFixedBucketTableWoPk()
}

@Test
public void testInsertIntoUnawareTable()
void testInsertIntoUnawareTable()
{
sql(
"INSERT INTO paimon.default.unaware_table VALUES (1,'1'),(2,'2'),(3,'3'),(4,'4'),(1,'1'),(2,'2'),(3,'3'),(4,'4')");
assertThat(sql("SELECT * FROM paimon.default.unaware_table order by id asc"))
.isEqualTo("[[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4]]");
}

protected String sql(String sql)
private String sql(String sql)
{
MaterializedResult result = getQueryRunner().execute(sql);
return result.getMaterializedRows().toString();
Expand Down
Loading

0 comments on commit d2fd4dc

Please sign in to comment.