Skip to content
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
@@ -0,0 +1,33 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.plugin.iceberg;

import com.google.inject.Inject;
import io.trino.spi.NodeManager;
import org.apache.iceberg.EnvironmentContext;

import static java.util.Objects.requireNonNull;
import static org.apache.iceberg.EnvironmentContext.ENGINE_NAME;
import static org.apache.iceberg.EnvironmentContext.ENGINE_VERSION;

public class IcebergEnvironmentContext
{
@Inject
public IcebergEnvironmentContext(NodeManager nodeManager)
{
requireNonNull(nodeManager, "nodeManager is null");
EnvironmentContext.put(ENGINE_NAME, "trino");
EnvironmentContext.put(ENGINE_VERSION, nodeManager.getCurrentNode().getVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public void configure(Binder binder)
binder.bind(IcebergFileWriterFactory.class).in(Scopes.SINGLETON);
newExporter(binder).export(IcebergFileWriterFactory.class).withGeneratedName();

binder.bind(IcebergEnvironmentContext.class).asEagerSingleton();

Multibinder<Procedure> procedures = newSetBinder(binder, Procedure.class);
procedures.addBinding().toProvider(RollbackToSnapshotProcedure.class).in(Scopes.SINGLETON);
procedures.addBinding().toProvider(RegisterTableProcedure.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
import static java.lang.String.format;
import static java.nio.ByteOrder.LITTLE_ENDIAN;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Map.entry;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.iceberg.FileFormat.ORC;
Expand Down Expand Up @@ -1508,6 +1509,16 @@ public void testUpdateAfterEqualityDelete()
}
}

@Test
void testEnvironmentContext()
{
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_environment_context", "(x int)")) {
Table icebergTable = loadTable(table.getName());
assertThat(icebergTable.currentSnapshot().summary())
.contains(entry("engine-name", "trino"), entry("engine-version", "testversion"));
}
}

private void testHighlyNestedFieldPartitioningWithTimestampTransform(String partitioning, String partitionDirectoryRegex, Set<String> expectedPartitionDirectories)
{
String tableName = "test_highly_nested_field_partitioning_with_timestamp_transform_" + randomNameSuffix();
Expand Down
Loading