2323import com .facebook .presto .spi .ConnectorTableLayoutResult ;
2424import com .facebook .presto .spi .ConnectorTableMetadata ;
2525import com .facebook .presto .spi .Constraint ;
26+ import com .facebook .presto .spi .PrestoException ;
2627import com .facebook .presto .spi .SchemaTableName ;
2728import com .facebook .presto .spi .SchemaTablePrefix ;
2829import com .facebook .presto .spi .TableNotFoundException ;
3839
3940import static com .facebook .presto .pinot .PinotColumnHandle .PinotColumnType .REGULAR ;
4041import static com .facebook .presto .pinot .PinotErrorCode .PINOT_UNCLASSIFIED_ERROR ;
42+ import static com .facebook .presto .spi .StandardErrorCode .NOT_FOUND ;
4143import static com .google .common .base .Preconditions .checkArgument ;
44+ import static java .lang .String .format ;
4245import static java .util .Locale .ROOT ;
4346import static java .util .Objects .requireNonNull ;
4447
@@ -48,6 +51,7 @@ public class PinotMetadata
4851 private final String connectorId ;
4952 private final PinotConnection pinotPrestoConnection ;
5053 private final PinotConfig pinotConfig ;
54+ private static final String SCHEMA_NAME = "default" ;
5155
5256 @ Inject
5357 public PinotMetadata (ConnectorId connectorId , PinotConnection pinotPrestoConnection , PinotConfig pinotConfig )
@@ -60,7 +64,7 @@ public PinotMetadata(ConnectorId connectorId, PinotConnection pinotPrestoConnect
6064 @ Override
6165 public List <String > listSchemaNames (ConnectorSession session )
6266 {
63- return ImmutableList .of ("default" );
67+ return ImmutableList .of (SCHEMA_NAME );
6468 }
6569
6670 private String getPinotTableNameFromPrestoTableName (String prestoTableName )
@@ -77,6 +81,9 @@ private String getPinotTableNameFromPrestoTableName(String prestoTableName)
7781 @ Override
7882 public PinotTableHandle getTableHandle (ConnectorSession session , SchemaTableName tableName )
7983 {
84+ if (!SCHEMA_NAME .equals (normalizeIdentifier (session , tableName .getSchemaName ()))) {
85+ throw new PrestoException (NOT_FOUND , format ("Schema %s does not exist" , tableName .getSchemaName ()));
86+ }
8087 String pinotTableName = getPinotTableNameFromPrestoTableName (tableName .getTableName ());
8188 return new PinotTableHandle (connectorId , tableName .getSchemaName (), pinotTableName );
8289 }
@@ -115,7 +122,7 @@ public List<SchemaTableName> listTables(ConnectorSession session, String schemaN
115122 {
116123 ImmutableList .Builder <SchemaTableName > builder = ImmutableList .builder ();
117124 for (String table : pinotPrestoConnection .getTableNames ()) {
118- builder .add (new SchemaTableName ("default" , table ));
125+ builder .add (new SchemaTableName (SCHEMA_NAME , table ));
119126 }
120127 return builder .build ();
121128 }
0 commit comments