Package com.facebook.presto.spi

Examples of com.facebook.presto.spi.SchemaTableName


            throws Exception
    {
        MetadataManager metadata = new MetadataManager();
        metadata.addConnectorMetadata("tpch", new InMemoryMetadata());

        SchemaTableName table1 = new SchemaTableName("default", "t1");
        metadata.createTable("tpch", new TableMetadata(table1,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", ColumnType.LONG, 0, false),
                        new ColumnMetadata("b", ColumnType.LONG, 1, false),
                        new ColumnMetadata("c", ColumnType.LONG, 2, false),
                        new ColumnMetadata("d", ColumnType.LONG, 3, false))));

        SchemaTableName table2 = new SchemaTableName("default", "t2");
        metadata.createTable("tpch", new TableMetadata(table2,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", ColumnType.LONG, 0, false),
                        new ColumnMetadata("b", ColumnType.LONG, 1, false))));

        SchemaTableName table3 = new SchemaTableName("default", "t3");
        metadata.createTable("tpch", new TableMetadata(table3,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", ColumnType.LONG, 0, false),
                        new ColumnMetadata("b", ColumnType.LONG, 1, false))));
View Full Code Here


    @BeforeMethod
    public void setUp()
            throws Exception
    {
        DualMetadata dualMetadata = new DualMetadata();
        tableHandle = dualMetadata.getTableHandle(new SchemaTableName("default", DualMetadata.NAME));
        assertNotNull(tableHandle, "tableHandle is null");
        ;
        columnHandle = dualMetadata.getColumnHandle(tableHandle, DualMetadata.COLUMN_NAME);
        assertNotNull(columnHandle, "columnHandle is null");
        symbol = new Symbol(DualMetadata.COLUMN_NAME);
View Full Code Here

        ConnectorTableHandle tableHandle = objectMapper.readValue(json, ConnectorTableHandle.class);
        assertEquals(tableHandle.getClass(), SystemTableHandle.class);
        SystemTableHandle systemHandle = (SystemTableHandle) tableHandle;

        assertEquals(systemHandle.getSchemaTableName(), new SchemaTableName("system_schema", "system_table"));
    }
View Full Code Here

        MetadataManager metadata = new MetadataManager(new FeaturesConfig().setExperimentalSyntaxEnabled(true), new TypeRegistry(), new SystemTablesMetadata());
        metadata.addConnectorMetadata("tpch", "tpch", new TestingMetadata());
        metadata.addConnectorMetadata("c2", "c2", new TestingMetadata());
        metadata.addConnectorMetadata("c3", "c3", new TestingMetadata());

        SchemaTableName table1 = new SchemaTableName("default", "t1");
        metadata.createTable(SESSION, "tpch", new TableMetadata("tpch", new ConnectorTableMetadata(table1,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", BIGINT, 0, false),
                        new ColumnMetadata("b", BIGINT, 1, false),
                        new ColumnMetadata("c", BIGINT, 2, false),
                        new ColumnMetadata("d", BIGINT, 3, false)))));

        SchemaTableName table2 = new SchemaTableName("default", "t2");
        metadata.createTable(SESSION, "tpch", new TableMetadata("tpch", new ConnectorTableMetadata(table2,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", BIGINT, 0, false),
                        new ColumnMetadata("b", BIGINT, 1, false)))));

        SchemaTableName table3 = new SchemaTableName("default", "t3");
        metadata.createTable(SESSION, "tpch", new TableMetadata("tpch", new ConnectorTableMetadata(table3,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", BIGINT, 0, false),
                        new ColumnMetadata("b", BIGINT, 1, false)))));

        // table in different catalog
        SchemaTableName table4 = new SchemaTableName("s2", "t4");
        metadata.createTable(SESSION, "c2", new TableMetadata("tpch", new ConnectorTableMetadata(table4,
                ImmutableList.<ColumnMetadata>of(
                        new ColumnMetadata("a", BIGINT, 0, false)))));

        // valid view referencing table in same schema
View Full Code Here

        HiveTableHandle tableHandle = objectMapper.readValue(json, HiveTableHandle.class);

        assertEquals(tableHandle.getClientId(), "hive");
        assertEquals(tableHandle.getSchemaName(), "hive_schema");
        assertEquals(tableHandle.getTableName(), "hive_table");
        assertEquals(tableHandle.getSchemaTableName(), new SchemaTableName("hive_schema", "hive_table"));
    }
View Full Code Here

            for (File file : listFiles(kafkaConnectorConfig.getTableDescriptionDir())) {
                if (file.isFile() && file.getName().endsWith(".json")) {
                    KafkaTopicDescription table = topicDescriptionCodec.fromJson(Files.toByteArray(file));
                    String schemaName = Objects.firstNonNull(table.getSchemaName(), kafkaConnectorConfig.getDefaultSchema());
                    log.debug("Kafka table %s.%s: %s", schemaName, table.getTableName(), table);
                    builder.put(new SchemaTableName(schemaName, table.getTableName()), table);
                }
            }

            Map<SchemaTableName, KafkaTopicDescription> tableDefinitions = builder.build();

            log.debug("Loaded Table definitions: %s", tableDefinitions.keySet());

            builder = ImmutableMap.builder();
            for (String definedTable : kafkaConnectorConfig.getTableNames()) {
                SchemaTableName tableName;
                try {
                    tableName = SchemaTableName.valueOf(definedTable);
                }
                catch (IllegalArgumentException iae) {
                    tableName = new SchemaTableName(kafkaConnectorConfig.getDefaultSchema(), definedTable);
                }

                if (tableDefinitions.containsKey(tableName)) {
                    KafkaTopicDescription kafkaTable = tableDefinitions.get(tableName);
                    log.debug("Found Table definition for %s: %s", tableName, kafkaTable);
                    builder.put(tableName, kafkaTable);
                }
                else {
                    // A dummy table definition only supports the internal columns.
                    log.debug("Created dummy Table definition for %s", tableName);
                    builder.put(tableName, new KafkaTopicDescription(tableName.getTableName(),
                            tableName.getSchemaName(),
                            definedTable,
                            new KafkaTopicFieldGroup(DummyKafkaRowDecoder.NAME, ImmutableList.<KafkaTopicFieldDescription>of()),
                            new KafkaTopicFieldGroup(DummyKafkaRowDecoder.NAME, ImmutableList.<KafkaTopicFieldDescription>of())));
                }
            }
View Full Code Here

        return messageDataFormat;
    }

    public SchemaTableName toSchemaTableName()
    {
        return new SchemaTableName(schemaName, tableName);
    }
View Full Code Here

    {
        checkNotNull(prefix, "prefix is null");

        ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();

        List<SchemaTableName> tableNames = prefix.getSchemaName() == null ? listTables(session, null) : ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));

        for (SchemaTableName tableName : tableNames) {
            ConnectorTableMetadata tableMetadata = getTableMetadata(tableName);
            // table can disappear during listing operation
            if (tableMetadata != null) {
View Full Code Here

                .toString();
    }

    public TableMetadata getTableMetadata()
    {
        return new TableMetadata(new SchemaTableName(JmxMetadata.SCHEMA_NAME, objectName), ImmutableList.copyOf(transform(columns, columnMetadataGetter())));
    }
View Full Code Here

        }

        Builder<SchemaTableName> tableNames = ImmutableList.builder();
        for (ObjectName objectName : mbeanServer.queryNames(WILDCARD, null)) {
            // todo remove lower case when presto supports mixed case names
            tableNames.add(new SchemaTableName(SCHEMA_NAME, objectName.toString().toLowerCase()));
        }
        return tableNames.build();
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.SchemaTableName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.