当前位置: 首页>>代码示例>>Java>>正文


Java ConnectorSession.getUser方法代码示例

本文整理汇总了Java中com.facebook.presto.spi.ConnectorSession.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectorSession.getUser方法的具体用法?Java ConnectorSession.getUser怎么用?Java ConnectorSession.getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.presto.spi.ConnectorSession的用法示例。


在下文中一共展示了ConnectorSession.getUser方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateTableUnsupportedType

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
@Test
public void testCreateTableUnsupportedType()
{
    for (HiveStorageFormat storageFormat : createTableFormats) {
        try {
            ConnectorSession session = newSession();
            List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata("dummy", HYPER_LOG_LOG, false));
            ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(invalidTable, columns, createTableProperties(storageFormat), session.getUser());
            metadata.beginCreateTable(session, tableMetadata);
            fail("create table with unsupported type should fail for storage format " + storageFormat);
        }
        catch (PrestoException e) {
            assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode());
        }
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:AbstractTestHiveClient.java

示例2: testTableCreationRollback

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
@Test
public void testTableCreationRollback()
        throws Exception
{
    try {
        ConnectorSession session = newSession();

        // begin creating the table
        ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(temporaryCreateRollbackTable, CREATE_TABLE_COLUMNS, createTableProperties(RCBINARY), session.getUser());

        ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(session, tableMetadata);

        // write the data
        ConnectorPageSink sink = pageSinkProvider.createPageSink(session, outputHandle);
        sink.appendPage(CREATE_TABLE_DATA.toPage(), null);
        sink.finish();

        // verify we have data files
        assertFalse(listAllDataFiles(outputHandle).isEmpty());

        // rollback the table
        metadata.rollbackCreateTable(session, outputHandle);

        // verify all files have been deleted
        assertTrue(listAllDataFiles(outputHandle).isEmpty());

        // verify table is not in the metastore
        assertNull(metadata.getTableHandle(session, temporaryCreateRollbackTable));
    }
    finally {
        dropTable(temporaryCreateRollbackTable);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:34,代码来源:AbstractTestHiveClient.java

示例3: createDummyTable

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
private void createDummyTable(SchemaTableName tableName)
{
    ConnectorSession session = newSession();
    List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata("dummy", VARCHAR, false));
    ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(tableName, columns, createTableProperties(TEXTFILE), session.getUser());
    ConnectorOutputTableHandle handle = metadata.beginCreateTable(session, tableMetadata);
    metadata.commitCreateTable(session, handle, ImmutableList.of());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:AbstractTestHiveClient.java

示例4: doCreateTable

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
protected void doCreateTable(SchemaTableName tableName, HiveStorageFormat storageFormat)
        throws Exception
{
    ConnectorSession session = newSession();

    // begin creating the table
    ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(tableName, CREATE_TABLE_COLUMNS, createTableProperties(storageFormat), session.getUser());

    ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(session, tableMetadata);

    // write the data
    ConnectorPageSink sink = pageSinkProvider.createPageSink(session, outputHandle);
    sink.appendPage(CREATE_TABLE_DATA.toPage(), null);
    Collection<Slice> fragments = sink.finish();

    // verify all new files start with the unique prefix
    for (String filePath : listAllDataFiles(outputHandle)) {
        assertTrue(new Path(filePath).getName().startsWith(getFilePrefix(outputHandle)));
    }

    // commit the table
    metadata.commitCreateTable(session, outputHandle, fragments);

    // load the new table
    ConnectorTableHandle tableHandle = getTableHandle(tableName);
    List<ColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(session, tableHandle).values());

    // verify the metadata
    tableMetadata = metadata.getTableMetadata(session, getTableHandle(tableName));
    assertEquals(tableMetadata.getOwner(), session.getUser());
    assertEquals(tableMetadata.getColumns(), CREATE_TABLE_COLUMNS);

    // verify the data
    MaterializedResult result = readTable(tableHandle, columnHandles, session, TupleDomain.all(), OptionalInt.empty(), Optional.of(storageFormat));
    assertEqualsIgnoreOrder(result.getMaterializedRows(), CREATE_TABLE_DATA.getMaterializedRows());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:37,代码来源:AbstractTestHiveClient.java

示例5: createView

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
@Override
public void createView(ConnectorSession session, SchemaTableName viewName, String viewData, boolean replace)
{
    if (replace) {
        try {
            dropView(session, viewName);
        }
        catch (ViewNotFoundException ignored) {
        }
    }

    Map<String, String> properties = ImmutableMap.<String, String>builder()
            .put("comment", "Presto View")
            .put(PRESTO_VIEW_FLAG, "true")
            .build();

    FieldSchema dummyColumn = new FieldSchema("dummy", STRING_TYPE_NAME, null);

    StorageDescriptor sd = new StorageDescriptor();
    sd.setCols(ImmutableList.of(dummyColumn));
    sd.setSerdeInfo(new SerDeInfo());

    Table table = new Table();
    table.setDbName(viewName.getSchemaName());
    table.setTableName(viewName.getTableName());
    table.setOwner(session.getUser());
    table.setTableType(TableType.VIRTUAL_VIEW.name());
    table.setParameters(properties);
    table.setViewOriginalText(encodeViewData(viewData));
    table.setViewExpandedText("/* Presto View */");
    table.setSd(sd);

    PrivilegeGrantInfo allPrivileges = new PrivilegeGrantInfo("all", 0, session.getUser(), PrincipalType.USER, true);
    table.setPrivileges(new PrincipalPrivilegeSet(
            ImmutableMap.of(session.getUser(), ImmutableList.of(allPrivileges)),
            ImmutableMap.of(),
            ImmutableMap.of()));

    try {
        metastore.createTable(table);
    }
    catch (TableAlreadyExistsException e) {
        throw new ViewAlreadyExistsException(e.getTableName());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:46,代码来源:HiveMetadata.java

示例6: doCreateSampledTable

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
protected void doCreateSampledTable(SchemaTableName tableName)
        throws Exception
{
    ConnectorSession session = newSession();

    // begin creating the table
    List<ColumnMetadata> columns = ImmutableList.<ColumnMetadata>builder()
            .add(new ColumnMetadata("sales", BIGINT, false))
            .build();

    ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(tableName, columns, createTableProperties(RCBINARY), session.getUser(), true);
    ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(session, tableMetadata);

    // write the records
    ConnectorPageSink sink = pageSinkProvider.createPageSink(session, outputHandle);

    BlockBuilder sampleBlockBuilder = BIGINT.createBlockBuilder(new BlockBuilderStatus(), 3);
    BlockBuilder dataBlockBuilder = BIGINT.createBlockBuilder(new BlockBuilderStatus(), 3);

    BIGINT.writeLong(sampleBlockBuilder, 8);
    BIGINT.writeLong(dataBlockBuilder, 2);

    BIGINT.writeLong(sampleBlockBuilder, 5);
    BIGINT.writeLong(dataBlockBuilder, 3);

    BIGINT.writeLong(sampleBlockBuilder, 7);
    BIGINT.writeLong(dataBlockBuilder, 4);

    sink.appendPage(new Page(dataBlockBuilder.build()), sampleBlockBuilder.build());

    Collection<Slice> fragments = sink.finish();

    // commit the table
    metadata.commitCreateTable(session, outputHandle, fragments);

    // load the new table
    ConnectorTableHandle tableHandle = getTableHandle(tableName);
    List<ColumnHandle> columnHandles = ImmutableList.<ColumnHandle>builder()
            .addAll(metadata.getColumnHandles(session, tableHandle).values())
            .add(metadata.getSampleWeightColumnHandle(session, tableHandle))
            .build();
    assertEquals(columnHandles.size(), 2);

    // verify the metadata
    tableMetadata = metadata.getTableMetadata(session, getTableHandle(tableName));
    assertEquals(tableMetadata.getOwner(), session.getUser());

    Map<String, ColumnMetadata> columnMap = uniqueIndex(tableMetadata.getColumns(), ColumnMetadata::getName);
    assertEquals(columnMap.size(), 1);

    assertPrimitiveField(columnMap, "sales", BIGINT, false);

    // verify the data
    List<ConnectorTableLayoutResult> tableLayoutResults = metadata.getTableLayouts(session, tableHandle, new Constraint<>(TupleDomain.all(), bindings -> true), Optional.empty());
    ConnectorTableLayoutHandle layoutHandle = getOnlyElement(tableLayoutResults).getTableLayout().getHandle();
    assertEquals(getAllPartitions(layoutHandle).size(), 1);
    ConnectorSplitSource splitSource = splitManager.getSplits(session, layoutHandle);
    ConnectorSplit split = getOnlyElement(getAllSplits(splitSource));

    try (ConnectorPageSource pageSource = pageSourceProvider.createPageSource(session, split, columnHandles)) {
        assertPageSourceType(pageSource, RCBINARY);
        MaterializedResult result = materializeSourceDataStream(session, pageSource, getTypes(columnHandles));
        assertEquals(result.getRowCount(), 3);

        MaterializedRow row;

        row = result.getMaterializedRows().get(0);
        assertEquals(row.getField(0), 2L);
        assertEquals(row.getField(1), 8L);

        row = result.getMaterializedRows().get(1);
        assertEquals(row.getField(0), 3L);
        assertEquals(row.getField(1), 5L);

        row = result.getMaterializedRows().get(2);
        assertEquals(row.getField(0), 4L);
        assertEquals(row.getField(1), 7L);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:80,代码来源:AbstractTestHiveClient.java

示例7: doCreateEmptyTable

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
protected void doCreateEmptyTable(SchemaTableName tableName, HiveStorageFormat storageFormat, List<ColumnMetadata> createTableColumns)
        throws Exception
{
    ConnectorSession session = newSession();

    List<String> partitionedBy = createTableColumns.stream()
            .filter(ColumnMetadata::isPartitionKey)
            .map(ColumnMetadata::getName)
            .collect(toList());
    ConnectorTableMetadata tableMetadata = new ConnectorTableMetadata(tableName, createTableColumns, createTableProperties(storageFormat, partitionedBy), session.getUser());

    metadata.createTable(session, tableMetadata);

    // load the new table
    ConnectorTableHandle tableHandle = getTableHandle(tableName);

    // verify the metadata
    tableMetadata = metadata.getTableMetadata(session, getTableHandle(tableName));
    assertEquals(tableMetadata.getOwner(), session.getUser());

    List<ColumnMetadata> expectedColumns = createTableColumns.stream()
            .map(column -> new ColumnMetadata(
                    column.getName(),
                    column.getType(),
                    column.isPartitionKey(),
                    annotateColumnComment(column.getComment(), column.isPartitionKey()),
                    false))
            .collect(toList());
    assertEquals(tableMetadata.getColumns(), expectedColumns);

    // verify table format
    Table table = getMetastoreClient(tableName.getSchemaName()).getTable(tableName.getSchemaName(), tableName.getTableName()).get();
    if (!table.getSd().getInputFormat().equals(storageFormat.getInputFormat())) {
        assertEquals(table.getSd().getInputFormat(), storageFormat.getInputFormat());
    }

    // verify the table is empty
    List<ColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(session, tableHandle).values());
    MaterializedResult result = readTable(tableHandle, columnHandles, session, TupleDomain.all(), OptionalInt.empty(), Optional.of(storageFormat));
    assertEquals(result.getRowCount(), 0);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:42,代码来源:AbstractTestHiveClient.java

示例8: getTableHandle

import com.facebook.presto.spi.ConnectorSession; //导入方法依赖的package包/类
@Override
public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) {
  Path spreadsheetPath = getSpreadsheetBasePath(session.getUser());
  Path filePath = getSpreadsheetFilePath(session, spreadsheetPath, tableName.getSchemaName());
  return new SpreadsheetTableHandle(session.getUser(), tableName, filePath.toString());
}
 
开发者ID:fortitudetec,项目名称:presto-plugins,代码行数:7,代码来源:SpreadsheetMetadata.java


注:本文中的com.facebook.presto.spi.ConnectorSession.getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。