use of io.trino.spi.session.PropertyMetadata in project trino by trinodb.
the class PropertyMetadataUtil method durationProperty.
public static PropertyMetadata<Duration> durationProperty(String name, String description, Duration defaultValue, Consumer<Duration> validation, boolean hidden) {
return new PropertyMetadata<>(name, description, VARCHAR, Duration.class, defaultValue, hidden, object -> {
Duration value = Duration.valueOf((String) object);
validation.accept(value);
return value;
}, Duration::toString);
}
use of io.trino.spi.session.PropertyMetadata in project trino by trinodb.
the class TestRubixCaching method setup.
@BeforeClass
public void setup() throws IOException {
cacheStoragePath = getStoragePath("/");
config = new HdfsConfig();
List<PropertyMetadata<?>> hiveSessionProperties = getHiveSessionProperties(new HiveConfig(), new RubixEnabledConfig().setCacheEnabled(true), new OrcReaderConfig()).getSessionProperties();
context = new HdfsContext(TestingConnectorSession.builder().setPropertyMetadata(hiveSessionProperties).build());
nonCachingFileSystem = getNonCachingFileSystem();
}
use of io.trino.spi.session.PropertyMetadata in project trino by trinodb.
the class AbstractPropertiesSystemTable method cursor.
@Override
public final RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
InMemoryRecordSet.Builder table = InMemoryRecordSet.builder(tableMetadata);
List<CatalogName> catalogNames = transactionManager.getCatalogs(transactionId).keySet().stream().sorted().map(CatalogName::new).collect(toImmutableList());
for (CatalogName catalogName : catalogNames) {
catalogProperties.apply(catalogName).stream().sorted(Comparator.comparing(PropertyMetadata::getName)).forEach(propertyMetadata -> table.addRow(catalogName.toString(), propertyMetadata.getName(), firstNonNull(propertyMetadata.getDefaultValue(), "").toString(), propertyMetadata.getSqlType().toString(), propertyMetadata.getDescription()));
}
return table.build().cursor();
}
use of io.trino.spi.session.PropertyMetadata in project trino by trinodb.
the class PropertyMetadataUtil method dataSizeProperty.
public static PropertyMetadata<DataSize> dataSizeProperty(String name, String description, DataSize defaultValue, Consumer<DataSize> validation, boolean hidden) {
return new PropertyMetadata<>(name, description, VARCHAR, DataSize.class, defaultValue, hidden, object -> {
DataSize value = DataSize.valueOf((String) object);
validation.accept(value);
return value;
}, DataSize::toString);
}
use of io.trino.spi.session.PropertyMetadata in project trino by trinodb.
the class TableProceduresPropertyManager method getProperties.
public Map<String, Object> getProperties(CatalogName catalog, String procedureName, Map<String, Expression> sqlPropertyValues, Session session, PlannerContext plannerContext, AccessControl accessControl, Map<NodeRef<Parameter>, Expression> parameters) {
Map<String, PropertyMetadata<?>> supportedProperties = connectorProperties.get(new Key(catalog, procedureName));
if (supportedProperties == null) {
throw new TrinoException(NOT_FOUND, format("Catalog '%s' table procedure '%s' property not found", catalog, procedureName));
}
Map<String, Optional<Object>> propertyValues = evaluateProperties(sqlPropertyValues.entrySet().stream().map(entry -> new Property(new Identifier(entry.getKey()), entry.getValue())).collect(toImmutableList()), session, plannerContext, accessControl, parameters, true, supportedProperties, INVALID_PROCEDURE_ARGUMENT, format("catalog '%s' table procedure '%s' property", catalog, procedureName));
return propertyValues.entrySet().stream().filter(entry -> entry.getValue().isPresent()).collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().orElseThrow()));
}
Aggregations