Search in sources :

Example 1 with Schema

use of org.apache.hadoop.hive.metastore.api.Schema in project hive by apache.

the class Driver method getThriftSchema.

/**
 * Get a Schema with fields represented with Thrift DDL types
 */
public Schema getThriftSchema() throws Exception {
    Schema schema;
    try {
        schema = getSchema();
        if (schema != null) {
            List<FieldSchema> lst = schema.getFieldSchemas();
            // Go over the schema and convert type to thrift type
            if (lst != null) {
                for (FieldSchema f : lst) {
                    f.setType(ColumnType.typeToThriftType(f.getType()));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
    LOG.info("Returning Thrift schema: " + schema);
    return schema;
}
Also used : Schema(org.apache.hadoop.hive.metastore.api.Schema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) LockException(org.apache.hadoop.hive.ql.lockmgr.LockException) IOException(java.io.IOException) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) AuthorizationException(org.apache.hadoop.hive.ql.metadata.AuthorizationException)

Example 2 with Schema

use of org.apache.hadoop.hive.metastore.api.Schema in project hive by apache.

the class TestCliDriverMethods method testThatCliDriverPrintsNoHeaderForCommandsWithNoSchema.

// If the command has no schema, make sure nothing is printed
@Test
public void testThatCliDriverPrintsNoHeaderForCommandsWithNoSchema() throws CommandProcessorException {
    Schema mockSchema = mock(Schema.class);
    when(mockSchema.getFieldSchemas()).thenReturn(null);
    PrintStream mockOut = headerPrintingTestDriver(mockSchema);
    // Should not have tried to print any thing.
    verify(mockOut, never()).print(anyString());
}
Also used : PrintStream(java.io.PrintStream) Schema(org.apache.hadoop.hive.metastore.api.Schema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) Test(org.junit.Test)

Example 3 with Schema

use of org.apache.hadoop.hive.metastore.api.Schema in project hive by apache.

the class LlapCacheResourceProcessor method getSchema.

private Schema getSchema() {
    Schema sch = new Schema();
    sch.addToFieldSchemas(new FieldSchema("hostName", "string", ""));
    sch.addToFieldSchemas(new FieldSchema("purgedMemoryBytes", "string", ""));
    sch.putToProperties(SERIALIZATION_NULL_FORMAT, defaultNullString);
    return sch;
}
Also used : Schema(org.apache.hadoop.hive.metastore.api.Schema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema)

Example 4 with Schema

use of org.apache.hadoop.hive.metastore.api.Schema in project hive by apache.

the class LlapClusterResourceProcessor method getSchema.

private Schema getSchema() {
    Schema sch = new Schema();
    sch.addToFieldSchemas(new FieldSchema("applicationId", "string", ""));
    sch.addToFieldSchemas(new FieldSchema("workerIdentity", "string", ""));
    sch.addToFieldSchemas(new FieldSchema("hostname", "string", ""));
    sch.addToFieldSchemas(new FieldSchema("rpcPort", "string", ""));
    sch.addToFieldSchemas(new FieldSchema("memory", "string", ""));
    sch.addToFieldSchemas(new FieldSchema("vcores", "string", ""));
    sch.putToProperties(SERIALIZATION_NULL_FORMAT, defaultNullString);
    return sch;
}
Also used : Schema(org.apache.hadoop.hive.metastore.api.Schema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema)

Example 5 with Schema

use of org.apache.hadoop.hive.metastore.api.Schema in project hive by apache.

the class SetProcessor method getSchema.

// create a Schema object containing the give column
private Schema getSchema() {
    Schema sch = new Schema();
    FieldSchema tmpFieldSchema = new FieldSchema();
    tmpFieldSchema.setName(SET_COLUMN_NAME);
    tmpFieldSchema.setType(STRING_TYPE_NAME);
    sch.putToProperties(SERIALIZATION_NULL_FORMAT, defaultNullString);
    sch.addToFieldSchemas(tmpFieldSchema);
    return sch;
}
Also used : Schema(org.apache.hadoop.hive.metastore.api.Schema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema)

Aggregations

Schema (org.apache.hadoop.hive.metastore.api.Schema)11 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)10 IOException (java.io.IOException)4 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 FetchTask (org.apache.hadoop.hive.ql.exec.FetchTask)3 PrintStream (java.io.PrintStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ValidTxnList (org.apache.hadoop.hive.common.ValidTxnList)2 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)2 AuthorizationException (org.apache.hadoop.hive.ql.metadata.AuthorizationException)2 ParseException (org.apache.hadoop.hive.ql.parse.ParseException)2 TableDesc (org.apache.hadoop.hive.ql.plan.TableDesc)2 CommandProcessorException (org.apache.hadoop.hive.ql.processors.CommandProcessorException)2 TableSchema (org.apache.hive.service.cli.TableSchema)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1