Search in sources :

Example 1 with ParametricType

use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.

the class PluginManager method installPlugin.

public void installPlugin(Plugin plugin) {
    for (BlockEncodingFactory<?> blockEncodingFactory : plugin.getBlockEncodingFactories(blockEncodingManager)) {
        log.info("Registering block encoding %s", blockEncodingFactory.getName());
        blockEncodingManager.addBlockEncodingFactory(blockEncodingFactory);
    }
    for (Type type : plugin.getTypes()) {
        log.info("Registering type %s", type.getTypeSignature());
        typeRegistry.addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        log.info("Registering parametric type %s", parametricType.getName());
        typeRegistry.addParametricType(parametricType);
    }
    for (ConnectorFactory connectorFactory : plugin.getConnectorFactories()) {
        log.info("Registering connector %s", connectorFactory.getName());
        connectorManager.addConnectorFactory(connectorFactory);
    }
    for (Class<?> functionClass : plugin.getFunctions()) {
        log.info("Registering functions from %s", functionClass.getName());
        metadata.addFunctions(extractFunctions(functionClass));
    }
    for (ResourceGroupConfigurationManagerFactory configurationManagerFactory : plugin.getResourceGroupConfigurationManagerFactories()) {
        log.info("Registering resource group configuration manager %s", configurationManagerFactory.getName());
        resourceGroupManager.addConfigurationManagerFactory(configurationManagerFactory);
    }
    for (SystemAccessControlFactory accessControlFactory : plugin.getSystemAccessControlFactories()) {
        log.info("Registering system access control %s", accessControlFactory.getName());
        accessControlManager.addSystemAccessControlFactory(accessControlFactory);
    }
    for (EventListenerFactory eventListenerFactory : plugin.getEventListenerFactories()) {
        log.info("Registering event listener %s", eventListenerFactory.getName());
        eventListenerManager.addEventListenerFactory(eventListenerFactory);
    }
}
Also used : SystemAccessControlFactory(com.facebook.presto.spi.security.SystemAccessControlFactory) Type(com.facebook.presto.spi.type.Type) ParametricType(com.facebook.presto.spi.type.ParametricType) ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) ResourceGroupConfigurationManagerFactory(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManagerFactory) EventListenerFactory(com.facebook.presto.spi.eventlistener.EventListenerFactory) ParametricType(com.facebook.presto.spi.type.ParametricType)

Example 2 with ParametricType

use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.

the class TestMLQueries method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    MLPlugin plugin = new MLPlugin();
    for (Type type : plugin.getTypes()) {
        localQueryRunner.getTypeManager().addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        localQueryRunner.getTypeManager().addParametricType(parametricType);
    }
    localQueryRunner.getMetadata().addFunctions(extractFunctions(new MLPlugin().getFunctions()));
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) Type(com.facebook.presto.spi.type.Type) ParametricType(com.facebook.presto.spi.type.ParametricType) ParametricType(com.facebook.presto.spi.type.ParametricType) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session)

Example 3 with ParametricType

use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.

the class TypesJdbcTable method addParametricTypeRows.

private static void addParametricTypeRows(Builder builder, Collection<ParametricType> types) {
    for (ParametricType type : types) {
        String typeName = type.getName();
        builder.addRow(typeName, typeName.equalsIgnoreCase("array") ? Types.ARRAY : Types.JAVA_OBJECT, null, null, null, null, DatabaseMetaData.typeNullable, false, DatabaseMetaData.typePredNone, null, false, null, null, 0, 0, null, null, null);
    }
}
Also used : ParametricType(com.facebook.presto.spi.type.ParametricType)

Example 4 with ParametricType

use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.

the class TypeRegistry method instantiateParametricType.

private Type instantiateParametricType(TypeSignature signature) {
    List<TypeParameter> parameters = new ArrayList<>();
    for (TypeSignatureParameter parameter : signature.getParameters()) {
        TypeParameter typeParameter = TypeParameter.of(parameter, this);
        if (typeParameter == null) {
            return null;
        }
        parameters.add(typeParameter);
    }
    ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
    if (parametricType == null) {
        return null;
    }
    try {
        Type instantiatedType = parametricType.createType(parameters);
        //checkState(instantiatedType.equalsSignature(signature), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType, signature);
        return instantiatedType;
    } catch (IllegalArgumentException e) {
        // TODO: check whether a type constructor actually exists rather than failing when it doesn't. This will be possible in the next version of the type system
        return null;
    }
}
Also used : TypeParameter(com.facebook.presto.spi.type.TypeParameter) CharType.createCharType(com.facebook.presto.spi.type.CharType.createCharType) DecimalType(com.facebook.presto.spi.type.DecimalType) VarcharType.createVarcharType(com.facebook.presto.spi.type.VarcharType.createVarcharType) DecimalType.createDecimalType(com.facebook.presto.spi.type.DecimalType.createDecimalType) Type(com.facebook.presto.spi.type.Type) ParametricType(com.facebook.presto.spi.type.ParametricType) CharType(com.facebook.presto.spi.type.CharType) VarcharType.createUnboundedVarcharType(com.facebook.presto.spi.type.VarcharType.createUnboundedVarcharType) VarcharType(com.facebook.presto.spi.type.VarcharType) TypeSignatureParameter(com.facebook.presto.spi.type.TypeSignatureParameter) ArrayList(java.util.ArrayList) ParametricType(com.facebook.presto.spi.type.ParametricType)

Aggregations

ParametricType (com.facebook.presto.spi.type.ParametricType)4 Type (com.facebook.presto.spi.type.Type)3 Session (com.facebook.presto.Session)1 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)1 EventListenerFactory (com.facebook.presto.spi.eventlistener.EventListenerFactory)1 ResourceGroupConfigurationManagerFactory (com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManagerFactory)1 SystemAccessControlFactory (com.facebook.presto.spi.security.SystemAccessControlFactory)1 CharType (com.facebook.presto.spi.type.CharType)1 CharType.createCharType (com.facebook.presto.spi.type.CharType.createCharType)1 DecimalType (com.facebook.presto.spi.type.DecimalType)1 DecimalType.createDecimalType (com.facebook.presto.spi.type.DecimalType.createDecimalType)1 TypeParameter (com.facebook.presto.spi.type.TypeParameter)1 TypeSignatureParameter (com.facebook.presto.spi.type.TypeSignatureParameter)1 VarcharType (com.facebook.presto.spi.type.VarcharType)1 VarcharType.createUnboundedVarcharType (com.facebook.presto.spi.type.VarcharType.createUnboundedVarcharType)1 VarcharType.createVarcharType (com.facebook.presto.spi.type.VarcharType.createVarcharType)1 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)1 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)1 ArrayList (java.util.ArrayList)1