Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check table existence in Pinot connector #8859

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.airlift.log.Logger;
import io.trino.plugin.pinot.client.PinotClient;
import io.trino.plugin.pinot.query.AggregationExpression;
import io.trino.plugin.pinot.query.DynamicTable;
Expand Down Expand Up @@ -67,6 +68,8 @@
public class PinotMetadata
implements ConnectorMetadata
{
private static final Logger log = Logger.get(PinotMetadata.class);

private static final Object ALL_TABLES_CACHE_KEY = new Object();
private static final String SCHEMA_NAME = "default";
private static final String PINOT_COLUMN_NAME_PROPERTY = "pinotColumnName";
Expand Down Expand Up @@ -115,7 +118,15 @@ public PinotTableHandle getTableHandle(ConnectorSession session, SchemaTableName
DynamicTable dynamicTable = DynamicTableBuilder.buildFromPql(this, tableName);
return new PinotTableHandle(tableName.getSchemaName(), dynamicTable.getTableName(), TupleDomain.all(), OptionalLong.empty(), Optional.of(dynamicTable));
}
return new PinotTableHandle(tableName.getSchemaName(), tableName.getTableName());

try {
String pinotTableName = getPinotTableNameFromTrinoTableName(tableName.getTableName());
hashhar marked this conversation as resolved.
Show resolved Hide resolved
return new PinotTableHandle(tableName.getSchemaName(), pinotTableName);
}
catch (TableNotFoundException e) {
log.debug(e, "Table not found: %s", tableName);
return null;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,4 +796,20 @@ public void testLimitPushdown()
assertThat(query("SELECT string_col, long_col FROM " + ALL_TYPES_TABLE + " WHERE int_col >0 AND bool_col = 'false' LIMIT " + MAX_ROWS_PER_SPLIT_FOR_SEGMENT_QUERIES))
.isNotFullyPushedDown(LimitNode.class);
}

@Test
public void testCreateTable()
{
assertQueryFails("CREATE TABLE test_create_table (col INT)", "This connector does not support creating tables");
}

/**
* https://github.com/trinodb/trino/issues/8307
*/
@Test
public void testInformationSchemaColumnsTableNotExist()
{
assertThat(query("SELECT * FROM pinot.information_schema.columns WHERE table_name = 'table_not_exist'"))
.returnsEmptyResult();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ public void testTables()
assertEquals(withWeirdSchema.getTableName(), TestPinotSplitManager.realtimeOnlyTable.getTableName());
PinotTableHandle withAnotherSchema = metadata.getTableHandle(session, new SchemaTableName(TestPinotSplitManager.realtimeOnlyTable.getTableName(), TestPinotSplitManager.realtimeOnlyTable.getTableName()));
assertEquals(withAnotherSchema.getTableName(), TestPinotSplitManager.realtimeOnlyTable.getTableName());
PinotTableHandle withUppercaseTable = metadata.getTableHandle(session, new SchemaTableName("default", TEST_TABLE));
assertEquals(withUppercaseTable.getTableName(), "airlinestats");
}
}