Skip to content

Commit 00a1b2f

Browse files
authored
Merge branch 'master' into fd-parquet
2 parents fd84d24 + aaccb63 commit 00a1b2f

File tree

18 files changed

+184
-56
lines changed

18 files changed

+184
-56
lines changed

core/trino-main/src/main/java/io/trino/connector/CatalogConnector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public CatalogConnector(
5555
connectorName,
5656
catalogConnector,
5757
informationSchemaConnector,
58-
systemConnector);
58+
systemConnector,
59+
true);
5960
}
6061

6162
public CatalogHandle getCatalogHandle()

core/trino-main/src/main/java/io/trino/connector/system/CatalogSystemTable.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import io.trino.spi.connector.SystemTable;
3030
import io.trino.spi.predicate.TupleDomain;
3131

32+
import java.util.List;
33+
34+
import static com.google.common.collect.ImmutableList.toImmutableList;
3235
import static io.trino.metadata.MetadataListing.listCatalogs;
3336
import static io.trino.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder;
3437
import static io.trino.spi.connector.SystemTable.Distribution.SINGLE_COORDINATOR;
@@ -72,7 +75,10 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect
7275
{
7376
Session session = ((FullConnectorSession) connectorSession).getSession();
7477
Builder table = InMemoryRecordSet.builder(CATALOG_TABLE);
75-
for (CatalogInfo catalogInfo : listCatalogs(session, metadata, accessControl)) {
78+
List<CatalogInfo> catalogInfos = listCatalogs(session, metadata, accessControl).stream()
79+
.filter(CatalogInfo::loaded)
80+
.collect(toImmutableList());
81+
for (CatalogInfo catalogInfo : catalogInfos) {
7682
table.addRow(
7783
catalogInfo.catalogName(),
7884
catalogInfo.catalogName(),

core/trino-main/src/main/java/io/trino/metadata/Catalog.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ public class Catalog
3838
private final ConnectorServices catalogConnector;
3939
private final ConnectorServices informationSchemaConnector;
4040
private final ConnectorServices systemConnector;
41+
private final boolean loaded;
4142

4243
public Catalog(
4344
CatalogName catalogName,
4445
CatalogHandle catalogHandle,
4546
ConnectorName connectorName,
4647
ConnectorServices catalogConnector,
4748
ConnectorServices informationSchemaConnector,
48-
ConnectorServices systemConnector)
49+
ConnectorServices systemConnector,
50+
boolean loaded)
4951
{
5052
this.catalogName = requireNonNull(catalogName, "catalogName is null");
5153
this.catalogHandle = requireNonNull(catalogHandle, "catalogHandle is null");
@@ -54,21 +56,23 @@ public Catalog(
5456
this.catalogConnector = requireNonNull(catalogConnector, "catalogConnector is null");
5557
this.informationSchemaConnector = requireNonNull(informationSchemaConnector, "informationSchemaConnector is null");
5658
this.systemConnector = requireNonNull(systemConnector, "systemConnector is null");
59+
this.loaded = loaded;
5760
}
5861

5962
public static Catalog failedCatalog(CatalogName catalogName, CatalogHandle catalogHandle, ConnectorName connectorName)
6063
{
61-
return new Catalog(catalogName, catalogHandle, connectorName);
64+
return new Catalog(catalogName, catalogHandle, connectorName, false);
6265
}
6366

64-
private Catalog(CatalogName catalogName, CatalogHandle catalogHandle, ConnectorName connectorName)
67+
private Catalog(CatalogName catalogName, CatalogHandle catalogHandle, ConnectorName connectorName, boolean loaded)
6568
{
6669
this.catalogName = catalogName;
6770
this.catalogHandle = catalogHandle;
6871
this.connectorName = connectorName;
6972
this.catalogConnector = null;
7073
this.informationSchemaConnector = null;
7174
this.systemConnector = null;
75+
this.loaded = loaded;
7276
}
7377

7478
public CatalogName getCatalogName()
@@ -86,6 +90,11 @@ public ConnectorName getConnectorName()
8690
return connectorName;
8791
}
8892

93+
public boolean isLoaded()
94+
{
95+
return loaded;
96+
}
97+
8998
public boolean isFailed()
9099
{
91100
return catalogConnector == null;

core/trino-main/src/main/java/io/trino/metadata/CatalogInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import static java.util.Objects.requireNonNull;
2020

21-
public record CatalogInfo(String catalogName, CatalogHandle catalogHandle, ConnectorName connectorName)
21+
public record CatalogInfo(String catalogName, CatalogHandle catalogHandle, ConnectorName connectorName, boolean loaded)
2222
{
2323
public CatalogInfo
2424
{

core/trino-main/src/main/java/io/trino/metadata/Metadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Optional<ConnectorOutputMetadata> finishRefreshMaterializedView(
467467
Optional<CatalogHandle> getCatalogHandle(Session session, String catalogName);
468468

469469
/**
470-
* Gets all the loaded catalogs
470+
* Lists all defined catalogs (both loaded properly and failed ones).
471471
*/
472472
List<CatalogInfo> listCatalogs(Session session);
473473

core/trino-main/src/main/java/io/trino/operator/project/PageProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,9 @@ private ProcessBatchResult processBatch(int batchSize)
320320
blocks[i] = previouslyComputedResults[i].getRegion(0, batchSize);
321321
}
322322
else {
323+
SourcePage inputChannelsSourcePage = projection.getInputChannels().getInputChannels(page);
323324
expressionProfiler.start();
324-
Block result = projection.project(session, projection.getInputChannels().getInputChannels(page), positionsBatch);
325+
Block result = projection.project(session, inputChannelsSourcePage, positionsBatch);
325326
long projectionTimeNanos = expressionProfiler.stop(positionsBatch.size());
326327
metrics.recordProjectionTime(projectionTimeNanos);
327328

core/trino-main/src/main/java/io/trino/transaction/InMemoryTransactionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ private synchronized List<CatalogInfo> getActiveCatalogs()
423423
.distinct()
424424
.map(key -> registeredCatalogs.getOrDefault(key, Optional.empty()))
425425
.flatMap(Optional::stream)
426-
.map(catalog -> new CatalogInfo(catalog.getCatalogName().toString(), catalog.getCatalogHandle(), catalog.getConnectorName()))
426+
.map(catalog -> new CatalogInfo(catalog.getCatalogName().toString(), catalog.getCatalogHandle(), catalog.getConnectorName(), catalog.isLoaded()))
427427
.collect(toImmutableList());
428428
}
429429

@@ -436,7 +436,7 @@ private synchronized List<CatalogInfo> listCatalogs()
436436
return registeredCatalogs.values().stream()
437437
.filter(Optional::isPresent)
438438
.map(Optional::get)
439-
.map(catalog -> new CatalogInfo(catalog.getCatalogName().toString(), catalog.getCatalogHandle(), catalog.getConnectorName()))
439+
.map(catalog -> new CatalogInfo(catalog.getCatalogName().toString(), catalog.getCatalogHandle(), catalog.getConnectorName(), catalog.isLoaded()))
440440
.collect(toImmutableList());
441441
}
442442

lib/trino-geospatial-toolkit/src/main/java/io/trino/geospatial/GeometryUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ public static org.locationtech.jts.geom.Geometry jtsGeometryFromJson(String json
179179

180180
public static String jsonFromJtsGeometry(org.locationtech.jts.geom.Geometry geometry)
181181
{
182-
return new GeoJsonWriter().write(geometry);
182+
GeoJsonWriter geoJsonWriter = new GeoJsonWriter();
183+
geoJsonWriter.setEncodeCRS(false);
184+
return geoJsonWriter.write(geometry);
183185
}
184186
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package io.trino.geospatial;
15+
16+
import org.junit.jupiter.api.Test;
17+
import org.locationtech.jts.io.ParseException;
18+
import org.locationtech.jts.io.WKTReader;
19+
20+
import static io.trino.geospatial.GeometryUtils.jsonFromJtsGeometry;
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
23+
final class TestGeometryUtils
24+
{
25+
@Test
26+
void testJsonFromJtsGeometry()
27+
throws ParseException
28+
{
29+
String json = jsonFromJtsGeometry(new WKTReader().read("POINT (1 1)"));
30+
assertThat(json)
31+
.isNotNull()
32+
.doesNotContain("crs");
33+
}
34+
}

plugin/trino-openlineage/src/main/java/io/trino/plugin/openlineage/OpenLineageListener.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ public OpenLineageListener(OpenLineage openLineage, OpenLineageClient client, Op
8888
this.jobNamespace = listenerConfig.getNamespace().orElse(trinoURI.toString());
8989
this.datasetNamespace = trinoURI.toString();
9090
this.includeQueryTypes = ImmutableSet.copyOf(listenerConfig.getIncludeQueryTypes());
91-
this.interpolator = new FormatInterpolator(
92-
listenerConfig.getJobNameFormat(),
93-
OpenLineageJobInterpolatedValues.values());
91+
this.interpolator = new FormatInterpolator<>(listenerConfig.getJobNameFormat(), OpenLineageJobInterpolatedValues.values());
9492
}
9593

9694
@Override
@@ -291,9 +289,9 @@ private JobBuilder getBaseJobBuilder(QueryContext queryContext, QueryMetadata qu
291289
.namespace(this.jobNamespace)
292290
.name(interpolator.interpolate(new OpenLineageJobContext(queryContext, queryMetadata)))
293291
.facets(openLineage.newJobFacetsBuilder()
294-
.jobType(openLineage.newJobTypeJobFacet("BATCH", "TRINO", "QUERY"))
295-
.sql(openLineage.newSQLJobFacet(queryMetadata.getQuery(), "trino"))
296-
.build());
292+
.jobType(openLineage.newJobTypeJobFacet("BATCH", "TRINO", "QUERY"))
293+
.sql(openLineage.newSQLJobFacet(queryMetadata.getQuery(), "trino"))
294+
.build());
297295
}
298296

299297
private List<InputDataset> buildInputs(QueryMetadata queryMetadata)

0 commit comments

Comments
 (0)