15 package com.cloudera.impala.catalog;
17 import java.io.StringReader;
18 import java.util.List;
21 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
22 import org.apache.hadoop.hive.metastore.api.FieldSchema;
26 import com.cloudera.impala.analysis.SqlParser;
27 import com.cloudera.impala.analysis.SqlScanner;
28 import com.cloudera.impala.thrift.TCatalogObjectType;
29 import com.cloudera.impala.thrift.TTable;
30 import com.cloudera.impala.thrift.TTableDescriptor;
31 import com.cloudera.impala.thrift.TTableType;
67 public View(
TableId id, org.apache.hadoop.hive.metastore.api.Table msTable,
68 Db db, String
name, String owner) {
69 super(
id, msTable, db, name, owner);
77 super(null, null, null, alias, null);
83 public void load(
Table oldValue, HiveMetaStoreClient client,
87 List<FieldSchema> fieldSchemas = client.getFields(db_.getName(),
name_);
88 for (
int i = 0; i < fieldSchemas.size(); ++i) {
89 FieldSchema s = fieldSchemas.get(i);
91 Column col =
new Column(s.getName(), type, s.getComment(), i);
98 }
catch (TableLoadingException e) {
100 }
catch (Exception e) {
101 throw new TableLoadingException(
"Failed to load metadata for view: " +
name_, e);
107 super.loadFromThrift(t);
123 SqlScanner input =
new SqlScanner(
new StringReader(inlineViewDef_));
124 SqlParser
parser =
new SqlParser(input);
128 }
catch (Exception e) {
131 throw new TableLoadingException(
132 String.format(
"Failed to parse view-definition statement of view: " +
137 throw new TableLoadingException(String.format(
"View definition of %s.%s " +
151 throw new IllegalStateException(
"Cannot call getNumNodes() on a view.");
158 throw new IllegalStateException(
"Cannot call toThriftDescriptor() on a view.");
163 TTable view = super.toThrift();
164 view.setTable_type(TTableType.VIEW);
void addColumn(Column col)
TTableDescriptor toThriftDescriptor(Set< Long > referencedPartitions)
final boolean isLocalView_
View(String alias, QueryStmt queryStmt)
Type parseColumnType(FieldSchema fs)
String getOriginalViewDef()
View(TableId id, org.apache.hadoop.hive.metastore.api.Table msTable, Db db, String name, String owner)
org.apache.hadoop.hive.metastore.api.Table getMetaStoreTable()
String getInlineViewDef()
Table(TableId id, org.apache.hadoop.hive.metastore.api.Table msTable, Db db, String name, String owner)
TCatalogObjectType getCatalogObjectType()
void loadFromThrift(TTable t)
void load(Table oldValue, HiveMetaStoreClient client, org.apache.hadoop.hive.metastore.api.Table msTbl)