hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zs...@apache.org
Subject svn commit: r697291 [13/31] - in /hadoop/core/trunk: ./ src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/ src/contrib/hive/metastore/if/ src/contrib/hive/metastore/src/gen-javabean/org/apache/hadoop/hive/metastore/api/ src/contrib/hive/metastor...
Date Fri, 19 Sep 2008 23:56:35 GMT
Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java Fri Sep 19 16:56:30 2008
@@ -40,8 +40,13 @@
 import org.apache.hadoop.hive.metastore.api.Order;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
-import org.apache.hadoop.hive.serde.SerDe;
-import org.apache.hadoop.hive.serde.SerDeField;
+import org.apache.hadoop.hive.serde2.Deserializer;
+import org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe;
+import org.apache.hadoop.hive.serde2.SerDe;
+import org.apache.hadoop.hive.serde2.SerDeException;
+import org.apache.hadoop.hive.serde2.objectinspector.StructField;
+import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
+import org.apache.hadoop.hive.serde.Constants;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.mapred.InputFormat;
@@ -57,7 +62,7 @@
   static final private Log LOG = LogFactory.getLog("hive.ql.metadata.Table");
 
   private Properties schema;
-  private SerDe serDe;
+  private Deserializer deserializer;
   private URI uri;
   private Class<? extends InputFormat> inputFormatClass;
   private Class<? extends OutputFormat> outputFormatClass;
@@ -83,73 +88,77 @@
    *
    * @exception HiveException on internal error. Note not possible now, but in the future reserve the right to throw an exception
    */
-  public Table(String name, Properties schema, SerDe serDe, 
+  public Table(String name, Properties schema, Deserializer deserializer, 
       Class<? extends InputFormat<?, ?>> inputFormatClass,
       Class<? extends OutputFormat<?, ?>> outputFormatClass,
       URI dataLocation, Hive hive) throws HiveException {
     initEmpty();
-    this.getTTable().setTableName(name);
-    this.getTTable().getSd().setLocation(dataLocation.toASCIIString());
-    this.setInputFormatClass(inputFormatClass);
-    this.setOutputFormatClass(outputFormatClass);
-    this.setDataLocation(dataLocation);
     this.schema = schema;
-    this.serDe = serDe; //TODO: convert to SerDeInfo format
-    this.getTTable().getSd().getSerdeInfo().setSerializationLib(serDe.getClass().getName());
+    this.deserializer = deserializer; //TODO: convert to SerDeInfo format
+    this.getTTable().getSd().getSerdeInfo().setSerializationLib(deserializer.getShortName());
+    getTTable().setTableName(name);
+    getSerdeInfo().setSerializationLib(deserializer.getClass().getName());
+    setInputFormatClass(inputFormatClass);
+    setOutputFormatClass(outputFormatClass);
+    setDataLocation(dataLocation);
   }
   
   public Table(String name) {
     // fill in defaults
     initEmpty();
-    this.getTTable().setTableName(name);
-    this.getTTable().setDatabase(MetaStoreUtils.DEFAULT_DATABASE_NAME);
-    this.getTTable().getSd().getSerdeInfo().setSerializationLib(org.apache.hadoop.hive.serde.simple_meta.MetadataTypedColumnsetSerDe.class.getName());
-    this.getTTable().getSd().getSerdeInfo().setSerializationFormat("1");
+    getTTable().setTableName(name);
+    getTTable().setDbName(MetaStoreUtils.DEFAULT_DATABASE_NAME);
+    getSerdeInfo().setSerializationLib(MetadataTypedColumnsetSerDe.shortName());
+    getSerdeInfo().getParameters().put(Constants.SERIALIZATION_FORMAT, "1");
   }
   
   void initEmpty() {
-    this.setTTable(new org.apache.hadoop.hive.metastore.api.Table());
-    this.getTTable().setSd(new StorageDescriptor());
-    this.getTTable().getSd().setSerdeInfo(new SerDeInfo());
-    this.getTTable().getSd().setNumBuckets(-1);
-    this.getTTable().getSd().setBucketCols(new ArrayList<String>());
-    this.getTTable().getSd().setCols(new ArrayList<FieldSchema>());
-    this.getTTable().setPartitionKeys(new ArrayList<FieldSchema>());
-    this.getTTable().setParameters(new HashMap<String, String>());
-    this.getTTable().getSd().setParameters(new HashMap<String, String>());
-    this.getTTable().getSd().setSortCols(new ArrayList<Order>());
+    setTTable(new org.apache.hadoop.hive.metastore.api.Table());
+    getTTable().setSd(new StorageDescriptor());
+    getTTable().setPartitionKeys(new ArrayList<FieldSchema>());
+    getTTable().setParameters(new HashMap<String, String>());
+
+    StorageDescriptor sd = getTTable().getSd();
+    sd.setSerdeInfo(new SerDeInfo());
+    sd.setNumBuckets(-1);
+    sd.setBucketCols(new ArrayList<String>());
+    sd.setCols(new ArrayList<FieldSchema>());
+    sd.setParameters(new HashMap<String, String>());
+    sd.setSortCols(new ArrayList<Order>());
+    
+    sd.getSerdeInfo().setParameters(new HashMap<String, String>());
   }
   
   protected void initSerDe() throws HiveException {
-    if(this.serDe == null) {
+    if (deserializer == null) {
       try {
-        this.serDe = MetaStoreUtils.getSerDe(Hive.get().getConf(), this.getTTable());
+        deserializer = MetaStoreUtils.getDeserializer(Hive.get().getConf(), this.getTTable());
       } catch (MetaException e) {
         throw new HiveException(e);
       }
     }
   }
-  public void checkValidity() throws HiveException {
 
+  public void checkValidity() throws HiveException {
     // check for validity
-    String name = this.getTTable().getTableName();
+    String name = getTTable().getTableName();
     if (null == name || name.length() == 0 || !MetaStoreUtils.validateName(name)) {
       throw new HiveException("[" + name + "]: is not a valid table name");
     }
-    if (null == this.getSerDe()) {
+    if (null == getDeserializer()) {
       throw new HiveException("must specify a non-null serDe");
     }
-    if (null == this.getInputFormatClass()) {
+    if (null == getInputFormatClass()) {
       throw new HiveException("must specify an InputFormat class");
     }
-    if (null == this.getOutputFormatClass()) {
+    if (null == getOutputFormatClass()) {
       throw new HiveException("must specify an OutputFormat class");
     }
     return;
   }
 
   /**
-   * @param inputFormatClass the inputFormatClass to set
+   * @param inputFormatClass 
    */
   public void setInputFormatClass(Class<? extends InputFormat> inputFormatClass) {
     this.inputFormatClass = inputFormatClass;
@@ -157,7 +166,7 @@
   }
 
   /**
-   * @param outputFormatClass the outputFormatClass to set
+   * @param outputFormatClass 
    */
   public void setOutputFormatClass(Class<? extends OutputFormat> outputFormatClass) {
     this.outputFormatClass = outputFormatClass;
@@ -165,37 +174,37 @@
   }
 
   final public Properties getSchema()  {
-    return this.schema;
+    return schema;
   }
 
   final public Path getPath() {
-    return new Path(this.getTTable().getSd().getLocation());
+    return new Path(getTTable().getSd().getLocation());
   }
 
   final public String getName() {
-    return this.getTTable().getTableName();
+    return getTTable().getTableName();
   }
 
   final public URI getDataLocation() {
-    return this.uri;
+    return uri;
   }
 
-  final public SerDe getSerDe() {
-    return this.serDe;
+  final public Deserializer getDeserializer() {
+    return deserializer;
   }
 
   final public Class<? extends InputFormat> getInputFormatClass() {
-    return this.inputFormatClass;
+    return inputFormatClass;
   }
 
   final public Class<? extends OutputFormat> getOutputFormatClass() {
-    return this.outputFormatClass;
+    return outputFormatClass;
   }
 
   final public boolean isValidSpec(AbstractMap<String, String> spec) throws HiveException {
 
     // TODO - types need to be checked.
-    List<FieldSchema> partCols = this.getTTable().getPartitionKeys();
+    List<FieldSchema> partCols = getTTable().getPartitionKeys();
     if(partCols== null || (partCols.size() == 0)) {
       if (spec != null)
         throw new HiveException("table is not partitioned but partition spec exists: " + spec);
@@ -217,7 +226,7 @@
   }
   
   public void setProperty(String name, String value) {
-    this.getTTable().getParameters().put(name, value);
+    getTTable().getParameters().put(name, value);
   }
 
   /**
@@ -225,36 +234,31 @@
    *
    */
   public String getProperty(String name) {
-    return this.getTTable().getParameters().get(name);
+    return getTTable().getParameters().get(name);
   }
 
-  public Vector<SerDeField> getFields(String [] components) {
+  public Vector<StructField> getFields() {
 
-
-    Vector<SerDeField> fields = new Vector<SerDeField> ();
+    Vector<StructField> fields = new Vector<StructField> ();
     try {
-      SerDe decoder = getSerDe();
-      if (components == null || components.length == 0) {
-        // Expand out all the columns of the table
-        List<SerDeField> fld_lst = decoder.getFields(null);
-        for(SerDeField field: fld_lst) {
-          fields.add(field);
-        }
-      }
-      else {
-        for (int i = 0; i < components.length; i++) {
-          fields.add(decoder.getFieldFromExpression(null, components[i]));
-        }
+      Deserializer decoder = getDeserializer();
+
+      // Expand out all the columns of the table
+      StructObjectInspector structObjectInspector = (StructObjectInspector)decoder.getObjectInspector();
+      List<? extends StructField> fld_lst = structObjectInspector.getAllStructFieldRefs();
+      for(StructField field: fld_lst) {
+        fields.add(field);
       }
-    } catch (Exception e) {
+    } catch (SerDeException e) {
       throw new RuntimeException(e);
     }
     return fields;
   }
 
-  public SerDeField getField(String fld) {
+  public StructField getField(String fld) {
     try {
-      return getSerDe().getFieldFromExpression(null, fld);
+      StructObjectInspector structObjectInspector = (StructObjectInspector)getDeserializer().getObjectInspector();
+      return structObjectInspector.getStructFieldRef(fld);
     }
     catch (Exception e) {
       throw new RuntimeException(e);
@@ -271,25 +275,25 @@
   /**
    * @param serDe the serDe to set
    */
-  public void setSerDe(SerDe serDe) {
-    this.serDe = serDe;
+  public void setDeserializer(Deserializer deserializer) {
+    this.deserializer = deserializer;
   }
 
   public String toString() { 
-    return this.getTTable().getTableName();
+    return getTTable().getTableName();
   }
 
   public List<FieldSchema> getPartCols() {
-    List<FieldSchema> partKeys = this.getTTable().getPartitionKeys();
+    List<FieldSchema> partKeys = getTTable().getPartitionKeys();
     if(partKeys == null) {
       partKeys = new ArrayList<FieldSchema>();
-      this.getTTable().setPartitionKeys(partKeys);
+      getTTable().setPartitionKeys(partKeys);
     }
     return partKeys;
   }
   
   public boolean isPartitionKey(String colName) {
-    for (FieldSchema key : this.getPartCols()) {
+    for (FieldSchema key : getPartCols()) {
       if(key.getName().toLowerCase().equals(colName)) {
         return true;
       }
@@ -299,7 +303,7 @@
 
   //TODO merge this with getBucketCols function
   public String getBucketingDimensionId() {
-    List<String> bcols = this.getTTable().getSd().getBucketCols();
+    List<String> bcols = getTTable().getSd().getBucketCols();
     if(bcols == null || bcols.size() == 0) {
       return null;
     }
@@ -311,14 +315,6 @@
     return bcols.get(0);
   }
 
-  public String getSerializationFormat() {
-    return this.getTTable().getSd().getSerdeInfo().getSerializationFormat();
-  }
-
-  public void setSerializationFormat(String f) {
-    this.getTTable().getSd().getSerdeInfo().setSerializationFormat(f);
-  }
-
   /**
    * @return the tTable
    */
@@ -334,16 +330,8 @@
   }
 
   public void setDataLocation(URI uri2) {
-    this.uri = uri2;
-    this.getTTable().getSd().setLocation(uri2.toString());
-  }
-
-  public void setSerializationClass(String cls) {
-    this.getTTable().getSd().getSerdeInfo().setSerializationClass(cls);
-  }
-
-  public void setSerializationLib(String lib) {
-    this.getTTable().getSd().getSerdeInfo().setSerializationLib(lib);
+    uri = uri2;
+    getTTable().getSd().setLocation(uri2.toString());
   }
 
   public void setBucketCols(List<String> bucketCols) throws HiveException {
@@ -352,22 +340,18 @@
     }
 
     for (String col : bucketCols) {
-      if(!this.isField(col))
+      if(!isField(col))
         throw new HiveException("Bucket columns " + col + " is not part of the table columns" ); 
     }
-    this.getTTable().getSd().setBucketCols(bucketCols);
+    getTTable().getSd().setBucketCols(bucketCols);
   }
 
-  public void setSortCols(List<String> sortCols) throws HiveException {
-    List<Order> sortOrder = new ArrayList<Order>();
-    for (String col : sortCols) {
-      sortOrder.add(new Order(col, 1));
-    }
-    this.getTTable().getSd().setSortCols(sortOrder);
+  public void setSortCols(List<Order> sortOrder) throws HiveException {
+    getTTable().getSd().setSortCols(sortOrder);
   }
 
   private boolean isField(String col) {
-    for (FieldSchema field : this.getCols()) {
+    for (FieldSchema field : getCols()) {
       if(field.getName().equals(col)) {
         return true;
       }
@@ -376,31 +360,30 @@
   }
 
   public List<FieldSchema> getCols() {
-    return this.getTTable().getSd().getCols();
+    return getTTable().getSd().getCols();
   }
 
   public void setPartCols(List<FieldSchema> partCols) {
-    this.getTTable().setPartitionKeys(partCols);
+    getTTable().setPartitionKeys(partCols);
   }
 
   public String getDbName() {
-    return this.getTTable().getDatabase();
+    return getTTable().getDbName();
   }
 
   public int getNumBuckets() {
-    return this.getTTable().getSd().getNumBuckets();
+    return getTTable().getSd().getNumBuckets();
   }
   
   /**
-   * Replaces files in the partition with new data set specifed by srcf. Works by moving files
-   *
-   * @param srcf Files to be moved. Leaf Directories or Globbed File Paths
+   * Replaces files in the partition with new data set specified by srcf. Works by moving files
+   * @param srcf Files to be replaced. Leaf directories or globbed file paths
    */
   protected void replaceFiles(Path srcf) throws HiveException {
     FileSystem fs;
     try {
-      fs = FileSystem.get(this.getDataLocation(), Hive.get().getConf());
-      Hive.get().replaceFiles(srcf, new Path(this.getDataLocation().getPath()), fs);
+      fs = FileSystem.get(getDataLocation(), Hive.get().getConf());
+      Hive.get().replaceFiles(srcf, new Path(getDataLocation().getPath()), fs);
     } catch (IOException e) {
       throw new HiveException("addFiles: filesystem error in check phase", e);
     }
@@ -408,14 +391,13 @@
 
   /**
    * Inserts files specified into the partition. Works by moving files
-   *
-   * @param srcf Files to be moved. Leaf Directories or Globbed File Paths
+   * @param srcf Files to be moved. Leaf directories or globbed file paths
    */
   protected void copyFiles(Path srcf) throws HiveException {
     FileSystem fs;
     try {
-      fs = FileSystem.get(this.getDataLocation(), Hive.get().getConf());
-      Hive.get().copyFiles(srcf, new Path(this.getDataLocation().getPath()), fs);
+      fs = FileSystem.get(getDataLocation(), Hive.get().getConf());
+      Hive.get().copyFiles(srcf, new Path(getDataLocation().getPath()), fs);
     } catch (IOException e) {
       throw new HiveException("addFiles: filesystem error in check phase", e);
     }
@@ -423,7 +405,7 @@
 
   public void setInputFormatClass(String name) throws HiveException {
     try {
-      this.setInputFormatClass((Class<? extends InputFormat<WritableComparable, Writable>>)Class.forName(name));
+      setInputFormatClass((Class<? extends InputFormat<WritableComparable, Writable>>)Class.forName(name));
     } catch (ClassNotFoundException e) {
       throw new HiveException("Class not found: " + name, e);
     }
@@ -431,7 +413,7 @@
 
   public void setOutputFormatClass(String name) throws HiveException {
     try {
-      this.setOutputFormatClass((Class<? extends OutputFormat<WritableComparable, Writable>>)Class.forName(name));
+      setOutputFormatClass((Class<? extends OutputFormat<WritableComparable, Writable>>)Class.forName(name));
     } catch (ClassNotFoundException e) {
       throw new HiveException("Class not found: " + name, e);
     }
@@ -439,18 +421,18 @@
 
   
   public boolean isPartitioned() {
-    if(this.getPartCols() == null) {
+    if(getPartCols() == null) {
       return false;
     }
-    return (this.getPartCols().size() != 0);
+    return (getPartCols().size() != 0);
   }
 
   public void setFields(List<FieldSchema> fields) {
-    this.getTTable().getSd().setCols(fields);
+    getTTable().getSd().setCols(fields);
   }
 
   public void setNumBuckets(int nb) {
-    this.getTTable().getSd().setNumBuckets(nb);
+    getTTable().getSd().setNumBuckets(nb);
   }
 
   /**
@@ -493,56 +475,32 @@
     tTable.setRetention(retention);
   }
 
-  public String getSerializationLib() {
-    return this.getTTable().getSd().getSerdeInfo().getSerializationLib();
-  }
-
-  public String getSerializationClass() {
-    return this.getTTable().getSd().getSerdeInfo().getSerializationClass();
-  }
-
-  public void setIsCompressed(boolean b) {
-    this.getTTable().getSd().setIsCompressed(b);
-  }
-
-  public void setFieldDelim(String string) {
-    this.getTTable().getSd().getSerdeInfo().setFieldDelim(string);  
+  private SerDeInfo getSerdeInfo() {
+    return getTTable().getSd().getSerdeInfo();
   }
 
-  public void setCollectionItemDelim(String string) {
-    this.getTTable().getSd().getSerdeInfo().setCollectionItemDelim(string);  
-  }
-
-  public void setLineDelim(String string) {
-    this.getTTable().getSd().getSerdeInfo().setLineDelim(string);  
-  }
-
-  public void setMapKeyDelim(String string) {
-    this.getTTable().getSd().getSerdeInfo().setMapKeyDelim(string);  
-  }
-  
-  public String getFieldDelim() {
-    return this.getTTable().getSd().getSerdeInfo().getFieldDelim();
+  public void setSerializationLib(String lib) {
+    getSerdeInfo().setSerializationLib(lib);
   }
 
-  public String getCollectionItemDelim() {
-    return this.getTTable().getSd().getSerdeInfo().getCollectionItemDelim();
+  public String getSerializationLib() {
+    return getSerdeInfo().getSerializationLib();
   }
   
-  public String getLineDelim() {
-    return this.getTTable().getSd().getSerdeInfo().getLineDelim();
+  public String getSerdeParam(String param) {
+    return getSerdeInfo().getParameters().get(param);
   }
   
-  public String getMapKeyDelim() {
-    return this.getTTable().getSd().getSerdeInfo().getMapKeyDelim();
+  public String setSerdeParam(String param, String value) {
+    return getSerdeInfo().getParameters().put(param, value);
   }
 
   public List<String> getBucketCols() {
-    return this.getTTable().getSd().getBucketCols();
+    return getTTable().getSd().getBucketCols();
   }
 
   public List<Order> getSortCols() {
-    return this.getTTable().getSd().getSortCols();
+    return getTTable().getSd().getSortCols();
   }
 
   private static void getPartPaths(FileSystem fs, Path p, Vector<String> partPaths) throws IOException {
@@ -572,14 +530,14 @@
   }
 
   static final Pattern pat = Pattern.compile("([^/]+)=([^/]+)");
-  protected List<Partition> getPartitionsFromHDFS() throws HiveException {
+  public List<Partition> getPartitionsFromHDFS() throws HiveException {
     ArrayList<Partition> ret = new ArrayList<Partition> ();
     FileSystem fs = null;
     Vector<String> partPaths = new Vector<String>();
 
     try {
-      fs = FileSystem.get(this.getDataLocation(), Hive.get().getConf());
-      getPartPaths(fs, new Path(this.getDataLocation().getPath()), partPaths);
+      fs = FileSystem.get(getDataLocation(), Hive.get().getConf());
+      getPartPaths(fs, new Path(getDataLocation().getPath()), partPaths);
       for(String partPath: partPaths) {
         Path tmpPath = new Path(partPath);
         if(!fs.getFileStatus(tmpPath).isDir()) {
@@ -589,11 +547,10 @@
       }
     } catch (IOException e) {
       LOG.error(StringUtils.stringifyException(e));
-      throw new HiveException("DB Error: Table " + this.getDataLocation() + " message: " + e.getMessage());
+      throw new HiveException("DB Error: Table " + getDataLocation() + " message: " + e.getMessage());
     }
 
     return ret;
   }
   
-  
 };

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java Fri Sep 19 16:56:30 2008
@@ -21,6 +21,7 @@
 import java.util.*;
 import java.io.File;
 import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,6 +34,7 @@
 import org.apache.hadoop.hive.ql.exec.TaskFactory;
 import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
 
+
 public abstract class BaseSemanticAnalyzer {
   protected String scratchDir;
   protected int randomid;
@@ -79,7 +81,39 @@
     }
     return val;
   }
-  
+
+  public static String charSetString(String charSetName, String charSetString) 
+    throws SemanticException {
+    try
+    {
+      // The character set name starts with a _, so strip that
+      charSetName = charSetName.substring(1);
+      if (charSetString.charAt(0) == '\'')
+        return new String(unescapeSQLString(charSetString).getBytes(), charSetName);
+      else                                       // hex input is also supported
+      {
+        assert charSetString.charAt(0) == '0';
+        assert charSetString.charAt(1) == 'x';
+        charSetString = charSetString.substring(2);
+        
+        byte[] bArray = new byte[charSetString.length()/2];
+        int j = 0;
+        for (int i = 0; i < charSetString.length(); i += 2)
+        {
+          int val = Character.digit(charSetString.charAt(i), 16) * 16 + Character.digit(charSetString.charAt(i+1), 16);
+          if (val > 127)
+            val = val - 256;
+          bArray[j++] = new Integer(val).byteValue();
+        }
+
+        String res = new String(bArray, charSetName);
+        return res;
+      } 
+    } catch (UnsupportedEncodingException e) {
+      throw new SemanticException(e);
+    }
+  }
+
   @SuppressWarnings("nls")
   public static String unescapeSQLString(String b) {
     assert(b.charAt(0) == '\'');

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java Fri Sep 19 16:56:30 2008
@@ -18,9 +18,10 @@
 
 package org.apache.hadoop.hive.ql.parse;
 
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.metastore.MetaStoreUtils;
-import org.apache.hadoop.hive.metastore.api.Constants;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Order;
 
 import org.antlr.runtime.tree.CommonTree;
 
@@ -35,11 +36,11 @@
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.serde.Constants;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.File;
 import java.util.*;
 
 public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer {
@@ -76,12 +77,12 @@
        analyzeDropTable(ast);
     else if (ast.getToken().getType() == HiveParser.TOK_DESCTABLE)
     {
-      ctx.setResFile(new File(getTmpFileName()));
+      ctx.setResFile(new Path(getTmpFileName()));
       analyzeDescribeTable(ast);
     }
     else if (ast.getToken().getType() == HiveParser.TOK_SHOWTABLES)
     {
-      ctx.setResFile(new File(getTmpFileName()));
+      ctx.setResFile(new Path(getTmpFileName()));
       analyzeShowTables(ast);
     }
     else if (ast.getToken().getType() == HiveParser.TOK_ALTERTABLE_RENAME)
@@ -97,14 +98,14 @@
     List<FieldSchema> cols          = getColumns(colList);
     List<FieldSchema> partCols      = null;
     List<String>      bucketCols    = null;
-    List<String>      sortCols      = null;
+    List<Order>       sortCols      = null;
     int               numBuckets    = -1;
     String            fieldDelim    = null;
     String            collItemDelim = null;
     String            mapKeyDelim   = null;
     String            lineDelim     = null;
     String            comment       = null;
-    boolean           isCompressed  = false;
+    boolean           isSequenceFile  = false;
     String            location      = null;
 
     LOG.info("Creating table" + tableName);
@@ -125,7 +126,7 @@
             numBuckets = (Integer.valueOf(child.getChild(1).getText())).intValue();
           else
           {
-            sortCols = getColumnNames((CommonTree)child.getChild(1));
+            sortCols = getColumnNamesOrder((CommonTree)child.getChild(1));
             numBuckets = (Integer.valueOf(child.getChild(2).getText())).intValue();
           }
           break;
@@ -151,8 +152,8 @@
             }
           }
           break;
-        case HiveParser.TOK_TBLCOMPRESSED:
-          isCompressed = true;
+        case HiveParser.TOK_TBLSEQUENCEFILE:
+          isSequenceFile = true;
           break;
         case HiveParser.TOK_TABLELOCATION:
           location = unescapeSQLString(child.getChild(0).getText());
@@ -165,7 +166,7 @@
       new createTableDesc(tableName, isExt, cols, partCols, bucketCols, 
                           sortCols, numBuckets,
                           fieldDelim, collItemDelim, mapKeyDelim, lineDelim,
-                          comment, isCompressed, location);
+                          comment, isSequenceFile, location);
 
     validateCreateTable(crtTblDesc);
     rootTasks.add(TaskFactory.get(new DDLWork(crtTblDesc), conf));
@@ -212,9 +213,9 @@
     if (crtTblDesc.getSortCols() != null)
     {
       // all columns in cluster and sort are valid columns
-      Iterator<String> sortCols = crtTblDesc.getSortCols().iterator();
+      Iterator<Order> sortCols = crtTblDesc.getSortCols().iterator();
       while (sortCols.hasNext()) {
-        String sortCol = sortCols.next();
+        String sortCol = sortCols.next().getCol();
         boolean found = false;
         Iterator<String> colNamesIter = colNames.iterator();
         while (colNamesIter.hasNext()) {
@@ -288,7 +289,21 @@
     int numCh = ast.getChildCount();
     for (int i = 0; i < numCh; i++) {
       CommonTree child = (CommonTree)ast.getChild(i);
-      colList.add(child.getChild(0).getText());
+      colList.add(child.getText());
+    }
+    return colList;
+  }
+
+  private List<Order> getColumnNamesOrder(CommonTree ast)
+  {
+    List<Order> colList = new ArrayList<Order>();
+    int numCh = ast.getChildCount();
+    for (int i = 0; i < numCh; i++) {
+      CommonTree child = (CommonTree)ast.getChild(i);
+      if (child.getToken().getType() == HiveParser.TOK_TABSORTCOLNAMEASC)
+        colList.add(new Order(child.getChild(0).getText(), 1));
+      else
+        colList.add(new Order(child.getChild(0).getText(), 0));
     }
     return colList;
   }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java Fri Sep 19 16:56:30 2008
@@ -21,6 +21,7 @@
 import java.io.File;
 
 import org.antlr.runtime.tree.CommonTree;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.Context;
 import org.apache.hadoop.hive.ql.exec.TaskFactory;
@@ -44,7 +45,7 @@
       extended = true;
     }
     
-    ctx.setResFile(new File(getTmpFileName()));
+    ctx.setResFile(new Path(getTmpFileName()));
     
     rootTasks.add(TaskFactory.get(new explainWork(ctx.getResFile(),
                                                   sem.getRootTasks(),

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/Hive.g Fri Sep 19 16:56:30 2008
@@ -92,11 +92,14 @@
 TOK_TABLEROWFORMATCOLLITEMS;
 TOK_TABLEROWFORMATMAPKEYS;
 TOK_TABLEROWFORMATLINES;
-TOK_TBLCOMPRESSED;
+TOK_TBLSEQUENCEFILE;
 TOK_TABCOLNAME;
 TOK_TABLELOCATION;
 TOK_TABLESAMPLE;
 TOK_TMP_FILE;
+TOK_TABSORTCOLNAMEASC;
+TOK_TABSORTCOLNAMEDESC;
+TOK_CHARSETLITERAL;
 TOK_CREATEFUNCTION;
 TOK_EXPLAIN;
 }
@@ -146,9 +149,9 @@
     ;
 
 createStatement
-    : KW_CREATE (ext=KW_EXTERNAL)? KW_TABLE name=Identifier LPAREN columnNameTypeList RPAREN tableComment? tablePartition? tableBuckets? tableRowFormat? tableCompress? tableLocation?
-    -> {$ext == null}? ^(TOK_CREATETABLE $name columnNameTypeList tableComment? tablePartition? tableBuckets? tableRowFormat? tableCompress? tableLocation?)
-    ->                 ^(TOK_CREATEEXTTABLE $name columnNameTypeList tableComment? tablePartition? tableBuckets? tableRowFormat? tableCompress? tableLocation?)
+    : KW_CREATE (ext=KW_EXTERNAL)? KW_TABLE name=Identifier LPAREN columnNameTypeList RPAREN tableComment? tablePartition? tableBuckets? tableRowFormat? tableFileFormat? tableLocation?
+    -> {$ext == null}? ^(TOK_CREATETABLE $name columnNameTypeList tableComment? tablePartition? tableBuckets? tableRowFormat? tableFileFormat? tableLocation?)
+    ->                 ^(TOK_CREATEEXTTABLE $name columnNameTypeList tableComment? tablePartition? tableBuckets? tableRowFormat? tableFileFormat? tableLocation?)
     ;
 
 dropStatement
@@ -200,7 +203,7 @@
 
 tableBuckets
     :
-      KW_CLUSTERED KW_BY LPAREN bucketCols=columnNameList RPAREN (KW_SORTED KW_BY LPAREN sortCols=columnNameList RPAREN)? KW_INTO num=Number KW_BUCKETS 
+      KW_CLUSTERED KW_BY LPAREN bucketCols=columnNameList RPAREN (KW_SORTED KW_BY LPAREN sortCols=columnNameOrderList RPAREN)? KW_INTO num=Number KW_BUCKETS 
     -> ^(TOK_TABLEBUCKETS $bucketCols $sortCols? $num)
     ;
 
@@ -234,9 +237,9 @@
     -> ^(TOK_TABLEROWFORMATLINES $linesIdnt)
     ;
 
-tableCompress
+tableFileFormat
     :
-      KW_STORED KW_AS KW_COMPRESSED  -> TOK_TBLCOMPRESSED
+      KW_STORED KW_AS KW_SEQUENCEFILE  -> TOK_TBLSEQUENCEFILE
     ;
 
 tableLocation
@@ -257,6 +260,16 @@
       Identifier
     ;
 
+columnNameOrderList
+    : columnNameOrder (COMMA columnNameOrder)* -> ^(TOK_TABCOLNAME columnNameOrder+)
+    ;
+
+columnNameOrder
+    : Identifier (asc=KW_ASC | desc=KW_DESC)? 
+    -> {$desc == null}? ^(TOK_TABSORTCOLNAMEASC Identifier)
+    ->                  ^(TOK_TABSORTCOLNAMEDESC Identifier)
+    ;
+
 columnNameType
     : colName=Identifier colType (KW_COMMENT comment=StringLiteral)?    
     -> {$comment == null}? ^(TOK_TABCOL $colName colType)
@@ -538,9 +551,14 @@
     :
     Number
     | StringLiteral
+    | charSetStringLiteral
     | booleanValue 
-     ;
+    ;
 
+charSetStringLiteral
+    :
+    csName=CharSetName csLiteral=CharSetLiteral -> ^(TOK_CHARSETLITERAL $csName $csLiteral)
+    ;
 
 expression:
     precedenceOrExpression
@@ -772,7 +790,7 @@
 KW_KEYS: 'KEYS';
 KW_LINES: 'LINES';
 KW_STORED: 'STORED';
-KW_COMPRESSED: 'COMPRESSED';
+KW_SEQUENCEFILE: 'SEQUENCEFILE';
 KW_LOCATION: 'LOCATION';
 KW_TABLESAMPLE: 'TABLESAMPLE';
 KW_BUCKET: 'BUCKET';
@@ -825,6 +843,11 @@
     ;
 
 fragment
+HexDigit
+    : 'a'..'f' | 'A'..'F' 
+    ;
+
+fragment
 Digit
     :
     '0'..'9'
@@ -841,6 +864,12 @@
     '\'' (~'\'')* '\'' ( '\'' (~'\'')* '\'' )*
     ;
 
+CharSetLiteral
+    :    
+    StringLiteral 
+    | '0' 'X' (HexDigit|Digit)+
+    ;
+
 Number
     :
     (Digit)+ ( DOT (Digit)* (Exponent)? | Exponent)?
@@ -848,7 +877,12 @@
 
 Identifier
     :
-    (Letter | Digit | '_')+
+    (Letter | Digit) (Letter | Digit | '_')*
+    ;
+
+CharSetName
+    :
+    '_' (Letter | Digit | '_' | '-' | '.' | ':' )+
     ;
 
 WS  :  (' '|'\r'|'\t'|'\n') {$channel=HIDDEN;}
@@ -858,3 +892,5 @@
   : '--' (~('\n'|'\r'))*
     { $channel=HIDDEN; }
   ;
+
+

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/InputSignature.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/InputSignature.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/InputSignature.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/InputSignature.java Fri Sep 19 16:56:30 2008
@@ -23,6 +23,8 @@
 import java.lang.Object;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoFactory;
 
 /**
  * The input signature of a function or operator. The signature basically consists
@@ -57,7 +59,7 @@
     
     if (classList.length != 0) {
       for(Class<?> cl: classList) {
-        typeArray.add(TypeInfo.getPrimitiveTypeInfo(cl));
+        typeArray.add(TypeInfoFactory.getPrimitiveTypeInfo(cl));
       }
     }
   }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/PartitionPruner.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/PartitionPruner.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/PartitionPruner.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/PartitionPruner.java Fri Sep 19 16:56:30 2008
@@ -27,13 +27,11 @@
  */
 
 import java.util.*;
+
 import org.antlr.runtime.tree.*;
 
 import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator;
 import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluatorFactory;
-import org.apache.hadoop.hive.ql.exec.HiveObject;
-import org.apache.hadoop.hive.ql.exec.LabeledCompositeHiveObject;
-import org.apache.hadoop.hive.ql.exec.PrimitiveHiveObject;
 import org.apache.hadoop.hive.ql.metadata.*;
 import org.apache.hadoop.hive.ql.plan.exprNodeColumnDesc;
 import org.apache.hadoop.hive.ql.plan.exprNodeConstantDesc;
@@ -42,9 +40,16 @@
 import org.apache.hadoop.hive.ql.plan.exprNodeFuncDesc;
 import org.apache.hadoop.hive.ql.plan.exprNodeIndexDesc;
 import org.apache.hadoop.hive.ql.plan.exprNodeNullDesc;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoUtils;
 import org.apache.hadoop.hive.ql.udf.UDFOPAnd;
 import org.apache.hadoop.hive.ql.udf.UDFOPNot;
 import org.apache.hadoop.hive.ql.udf.UDFOPOr;
+import org.apache.hadoop.hive.serde2.SerDeException;
+import org.apache.hadoop.hive.serde2.objectinspector.InspectableObject;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -111,8 +116,13 @@
           desc = new exprNodeColumnDesc(String.class, colName); 
         } else {
           // might be a column from another table
-          TypeInfo typeInfo = new TypeInfo(this.metaData.getTableForAlias(tabAlias).getSerDe(), null);
-          desc = new exprNodeConstantDesc(typeInfo.getFieldType(colName), null);
+          try {
+            TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(
+                this.metaData.getTableForAlias(tabAlias).getDeserializer().getObjectInspector());
+            desc = new exprNodeConstantDesc(typeInfo.getStructFieldTypeInfo(colName), null);
+          } catch (SerDeException e){
+            throw new RuntimeException(e);
+          }
         }
         break;
       }
@@ -124,7 +134,9 @@
         int childrenBegin = (isFunction ? 1 : 0);
         ArrayList<exprNodeDesc> children = new ArrayList<exprNodeDesc>(expr.getChildCount() - childrenBegin);
         for (int ci=childrenBegin; ci<expr.getChildCount(); ci++) {
-          children.add(genExprNodeDesc((CommonTree)expr.getChild(ci)));
+          exprNodeDesc child = genExprNodeDesc((CommonTree)expr.getChild(ci));
+          assert(child.getTypeInfo() != null);
+          children.add(child);
         }
 
         // Create function desc
@@ -198,27 +210,36 @@
 
     HashSet<Partition> ret_parts = new HashSet<Partition>();
     try {
+      StructObjectInspector rowObjectInspector = (StructObjectInspector)this.tab.getDeserializer().getObjectInspector();
+      Object[] rowWithPart = new Object[2];
+      InspectableObject inspectableObject = new InspectableObject();
+      
       ExprNodeEvaluator evaluator = ExprNodeEvaluatorFactory.get(this.prunerExpr);
       for(Partition part: Hive.get().getPartitions(this.tab)) {
         // Set all the variables here
         LinkedHashMap<String, String> partSpec = part.getSpec();
 
         // Create the row object
-        String[] partNames = new String[partSpec.size()];
-        int i=0;
-        for(String name: partSpec.keySet()) {
-          partNames[i++] = name;
-        }
-        LabeledCompositeHiveObject hiveObject;
-        hiveObject = new LabeledCompositeHiveObject(partNames);
-        for(String s: partNames) {
-          hiveObject.addHiveObject(new PrimitiveHiveObject(partSpec.get(s)));
+        ArrayList<String> partNames = new ArrayList<String>();
+        ArrayList<String> partValues = new ArrayList<String>();
+        ArrayList<ObjectInspector> partObjectInspectors = new ArrayList<ObjectInspector>();
+        for(Map.Entry<String,String>entry : partSpec.entrySet()) {
+          partNames.add(entry.getKey());
+          partValues.add(entry.getValue());
+          partObjectInspectors.add(ObjectInspectorFactory.getStandardPrimitiveObjectInspector(String.class)); 
         }
+        StructObjectInspector partObjectInspector = ObjectInspectorFactory.getStandardStructObjectInspector(partNames, partObjectInspectors);
+        
+        rowWithPart[1] = partValues;
+        ArrayList<StructObjectInspector> ois = new ArrayList<StructObjectInspector>(2);
+        ois.add(rowObjectInspector);
+        ois.add(partObjectInspector);
+        StructObjectInspector rowWithPartObjectInspector = ObjectInspectorFactory.getUnionStructObjectInspector(ois);
         
         // evaluate the expression tree
-        HiveObject r = evaluator.evaluate(hiveObject);
-        LOG.trace("prune result for partition " + partSpec + ": " + r.getJavaObject());
-        if (!Boolean.FALSE.equals(r.getJavaObject())) {
+        evaluator.evaluate(rowWithPart, rowWithPartObjectInspector, inspectableObject);
+        LOG.trace("prune result for partition " + partSpec + ": " + inspectableObject.o);
+        if (!Boolean.FALSE.equals(inspectableObject.o)) {
           LOG.debug("retained partition: " + partSpec);
           ret_parts.add(part);
         } else {

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java Fri Sep 19 16:56:30 2008
@@ -23,7 +23,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.ql.exec.ColumnInfo;
 import org.apache.hadoop.hive.ql.exec.RowSchema;
-import org.apache.hadoop.hive.serde.ExpressionUtils;
 
 /**
  * Implementation of the Row Resolver
@@ -51,6 +50,7 @@
   }
   
   public void put(String tab_alias, String col_alias, ColumnInfo colInfo) {
+    col_alias = col_alias.toLowerCase();
     if (rowSchema.getSignature() == null) {
       rowSchema.setSignature(new Vector<ColumnInfo>());
     }
@@ -75,34 +75,14 @@
   }
 
   public ColumnInfo get(String tab_alias, String col_alias) {
+    col_alias = col_alias.toLowerCase();
     HashMap<String, ColumnInfo> f_map = rslvMap.get(tab_alias);
     if (f_map == null) {
       return null;
     }
-    ColumnInfo resInfo = f_map.get(col_alias.toLowerCase());
-    if(resInfo == null) {
-      // case insensitive search on column names but ANTLR Tokens are upppercase
-      // TODO: need to fix this in a better way
-      resInfo = f_map.get(col_alias);
-    }
-    if (resInfo == null) {
-      List<String> exprs = ExpressionUtils.decomposeComplexExpression(col_alias);
-      // Is this a complex field?
-      if (exprs.size() == 2) {
-        String topLevelField = exprs.get(0);
-        String suffix = exprs.get(1);
-        ColumnInfo info = f_map.get(topLevelField.toLowerCase());
-        if(info == null) {
-          info = f_map.get(topLevelField);
-        }
-        resInfo = new ColumnInfo(info.getInternalName() + suffix, 
-                                 info.getType().getFieldType(suffix),
-                                 info.getIsVirtual());
-      }
-    }
-    return resInfo; 
+    return f_map.get(col_alias);
   }
-   
+
   public Vector<ColumnInfo> getColumnInfos() {
     return rowSchema.getSignature();
   }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Fri Sep 19 16:56:30 2008
@@ -24,15 +24,19 @@
 import java.lang.reflect.Method;
 
 import org.antlr.runtime.tree.*;
-import org.apache.hadoop.hive.serde.SerDeField;
+import org.apache.hadoop.hive.serde2.SerDeException;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.objectinspector.StructField;
+import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.ql.Context;
-import org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat;
 import org.apache.hadoop.hive.ql.metadata.*;
 import org.apache.hadoop.hive.ql.plan.*;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoUtils;
 import org.apache.hadoop.hive.ql.exec.*;
 import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.mapred.TextInputFormat;
 
 import org.apache.hadoop.fs.Path;
 import org.apache.commons.lang.StringUtils;
@@ -560,6 +564,7 @@
 
     case HiveParser.Number:
     case HiveParser.StringLiteral:
+    case HiveParser.TOK_CHARSETLITERAL:
     case HiveParser.KW_TRUE:
     case HiveParser.KW_FALSE:
       break;
@@ -794,14 +799,9 @@
         .setOp(OperatorFactory
             .getAndMakeChild(
                 new scriptDesc(
-                               stripQuotes(trfm.getChild(2).getText()),
-                    new tableDesc(
-                        org.apache.hadoop.hive.serde.simple_meta.MetadataTypedColumnsetSerDe.class,
-                        TextInputFormat.class,
-                        IgnoreKeyTextOutputFormat.class,
-                        Utilities.makeProperties(
-                            org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, "" + Utilities.tabCode,
-                            "columns", sb.toString()))),
+                    stripQuotes(trfm.getChild(2).getText()),
+                    PlanUtils.getDefaultTableDesc(Integer.toString(Utilities.tabCode), sb.toString()),
+                    PlanUtils.getDefaultTableDesc(Integer.toString(Utilities.tabCode), "")),
                     new RowSchema(
                         out_rwsch.getColumnInfos()), input.get(0).getOp()));
 
@@ -840,6 +840,26 @@
     }
   }
   
+  private static String getColAlias(CommonTree selExpr, String defaultName) {
+    if (selExpr.getChildCount() == 2) {
+      // return zz for "xx + yy AS zz"
+      return selExpr.getChild(1).getText(); 
+    }
+
+    CommonTree root = (CommonTree)selExpr.getChild(0);
+    while (root.getType() == HiveParser.DOT || root.getType() == HiveParser.TOK_COLREF) {
+      assert(root.getChildCount() == 2);
+      root = (CommonTree) root.getChild(1);
+    }
+    if (root.getType() == HiveParser.Identifier) {
+      // Return zz for "xx.zz" and "xx.yy.zz"
+      return root.getText();
+    } else {
+      // Return defaultName if selExpr is not a simple xx.yy.zz 
+      return defaultName;
+    }
+  }
+  
   @SuppressWarnings("nls")
   private OperatorInfoList genSelectPlan(String dest, QB qb,
       OperatorInfoList input) throws SemanticException {
@@ -861,11 +881,7 @@
 
       // list of the columns
       CommonTree selExpr = (CommonTree) selExprList.getChild(i);
-      String colAlias = null;
-      if (selExpr.getChildCount() == 2)
-        colAlias = selExpr.getChild(1).getText();
-      else if (selExpr.getChild(0).getChildCount() >= 2)
-        colAlias = selExpr.getChild(0).getChild(1).getText();
+      String colAlias = getColAlias(selExpr, "_C" + i);
       CommonTree sel = (CommonTree)selExpr.getChild(0);
 
       if (sel.getToken().getType() == HiveParser.TOK_COLREF ||
@@ -909,6 +925,12 @@
       pos = Integer.valueOf(pos.intValue() + 1);
     }
 
+    for (int i=0; i<col_list.size(); i++) {
+      if (col_list.get(i) instanceof exprNodeNullDesc) {
+        col_list.set(i, new exprNodeConstantDesc(String.class, null));
+      }
+    }
+    
     OperatorInfoList output = (OperatorInfoList) input.clone();
     output.get(0).setOp(OperatorFactory.getAndMakeChild(
         new selectDesc(col_list), new RowSchema(out_rwsch.getColumnInfos()),
@@ -959,7 +981,7 @@
         QBParseInfo parseInfo, String dest, OperatorInfo reduceSinkOperatorInfo,
         groupByDesc.Mode mode)
     throws SemanticException {
-    RowResolver gropuByInputRowResolver = reduceSinkOperatorInfo.getRowResolver();
+    RowResolver groupByInputRowResolver = reduceSinkOperatorInfo.getRowResolver();
     RowResolver groupByOutputRowResolver = new RowResolver();
     groupByOutputRowResolver.setIsExprResolver(true);
     ArrayList<exprNodeDesc> groupByKeys = new ArrayList<exprNodeDesc>();
@@ -968,7 +990,7 @@
     for (int i = 0; i < grpByExprs.size(); ++i) {
       CommonTree grpbyExpr = grpByExprs.get(i);
       String text = grpbyExpr.toStringTree();
-      ColumnInfo exprInfo = gropuByInputRowResolver.get("",text);
+      ColumnInfo exprInfo = groupByInputRowResolver.get("",text);
 
       if (exprInfo == null) {
         throw new SemanticException(ErrorMsg.INVALID_COLUMN.getMsg(grpbyExpr));
@@ -995,7 +1017,7 @@
       for (int i = 1; i < value.getChildCount(); i++) {
         String text = value.getChild(i).toStringTree();
         CommonTree paraExpr = (CommonTree)value.getChild(i);
-        ColumnInfo paraExprInfo = gropuByInputRowResolver.get("",text);
+        ColumnInfo paraExprInfo = groupByInputRowResolver.get("",text);
         if (paraExprInfo == null) {
           throw new SemanticException(ErrorMsg.INVALID_COLUMN.getMsg(paraExpr));
         }
@@ -1159,7 +1181,7 @@
     }
 
     return new OperatorInfo(
-        OperatorFactory.getAndMakeChild(new reduceSinkDesc(reduceKeys, reduceValues, numPartitionFields),
+        OperatorFactory.getAndMakeChild(PlanUtils.getReduceSinkDesc(reduceKeys, reduceValues, numPartitionFields),
                                         new RowSchema(reduceSinkOutputRowResolver.getColumnInfos()),
                                         inputOperatorInfo.getOp()),
         reduceSinkOutputRowResolver
@@ -1185,8 +1207,10 @@
         new ColumnInfo(Utilities.ReduceField.KEY.toString() + "." + Integer.valueOf(reduceKeys.size() - 1).toString(),
                        String.class, false));
     }
-    else
-      reduceKeys.add(new exprNodeNullDesc());
+    else {
+      // dummy key
+      reduceKeys.add(new exprNodeConstantDesc(0));
+    }
 
     // copy the input row resolver
     ArrayList<exprNodeDesc> reduceValues = new ArrayList<exprNodeDesc>();
@@ -1246,7 +1270,7 @@
     }
 
     return new OperatorInfo(
-        OperatorFactory.getAndMakeChild(new reduceSinkDesc(reduceKeys, reduceValues, distinctText == null ? -1 : 1),
+        OperatorFactory.getAndMakeChild(PlanUtils.getReduceSinkDesc(reduceKeys, reduceValues, distinctText == null ? -1 : 1),
                                         new RowSchema(outputRS.getColumnInfos()), input.getOp()),
         outputRS);
   }
@@ -1278,7 +1302,7 @@
     for (int i = 0; i < grpByExprs.size(); ++i) {
       CommonTree grpbyExpr = grpByExprs.get(i);
       String field = (Integer.valueOf(i)).toString();
-      reduceKeys.add(new exprNodeColumnDesc(TypeInfo.getPrimitiveTypeInfo(String.class), field));
+      reduceKeys.add(new exprNodeColumnDesc(TypeInfoFactory.getPrimitiveTypeInfo(String.class), field));
       reduceSinkOutputRowResolver2.put("", grpbyExpr.toStringTree(),
                                        new ColumnInfo(Utilities.ReduceField.KEY.toString() + "." + field,
                                                       String.class, false)); // Everything is a string right now
@@ -1289,7 +1313,7 @@
     HashMap<String, CommonTree> aggregationTrees = parseInfo
         .getAggregationExprsForClause(dest);
     for (Map.Entry<String, CommonTree> entry : aggregationTrees.entrySet()) {
-      reduceValues.add(new exprNodeColumnDesc(TypeInfo.getPrimitiveTypeInfo(String.class),
+      reduceValues.add(new exprNodeColumnDesc(TypeInfoFactory.getPrimitiveTypeInfo(String.class),
           (Integer.valueOf(inputField)).toString()));
       inputField++;
       reduceSinkOutputRowResolver2.put("", ((CommonTree)entry.getValue()).toStringTree(),
@@ -1298,7 +1322,7 @@
     }
 
     return new OperatorInfo(
-        OperatorFactory.getAndMakeChild(new reduceSinkDesc(reduceKeys, reduceValues, numPartitionFields),
+        OperatorFactory.getAndMakeChild(PlanUtils.getReduceSinkDesc(reduceKeys, reduceValues, numPartitionFields),
                                         new RowSchema(reduceSinkOutputRowResolver2.getColumnInfos()),
                                         groupByOperatorInfo.getOp()),
         reduceSinkOutputRowResolver2
@@ -1532,16 +1556,24 @@
       }
     }
 
+    /*
     // We have the table object here - go over the row resolver
     // and check all the types are the same
-    input.get(0).getRowResolver().getColumnInfos();
+    // Vector<ColumnInfo> srcOpns = input.get(0).getRowResolver().getColumnInfos();
 
     Vector<ColumnInfo> insOpns = new Vector<ColumnInfo>();
-    for (SerDeField field : dest_tab.getFields(null)) {
-      insOpns.add(new ColumnInfo(field.getName(), new TypeInfo(dest_tab.getSerDe(), field), false));
+    try {
+      StructObjectInspector rowObjectInspector = (StructObjectInspector)dest_tab.getDeserializer().getObjectInspector();
+      List<? extends StructField> fields = rowObjectInspector.getAllStructFieldRefs();
+      for (int i=0; i<fields.size(); i++) {
+        insOpns.add(new ColumnInfo(
+            fields.get(i).getFieldName(),
+            TypeInfoUtils.getTypeInfoFromObjectInspector(fields.get(i).getFieldObjectInspector()),
+            false));
+      }
+    } catch (SerDeException e) {
+      throw new RuntimeException(e);
     }
-
-    /*
     if (insOpns.size() != srcOpns.size()) {
       // TODO: change this to error message later
       throw new SemanticException("Number of columns in the select expression does not " + 
@@ -1665,7 +1697,7 @@
     OperatorInfoList interim = (OperatorInfoList)input.clone();
     interim.get(0).setOp(
       OperatorFactory.getAndMakeChild(
-        new reduceSinkDesc(keyCols, valueCols, keyCols.size()),
+        PlanUtils.getReduceSinkDesc(keyCols, valueCols, keyCols.size()),
         new RowSchema(interim.get(0).getRowResolver().getColumnInfos()),
         input.get(0).getOp()
       )
@@ -1780,7 +1812,7 @@
       }
     }
 
-    return new OperatorInfo(OperatorFactory.getAndMakeChild(new reduceSinkDesc(
+    return new OperatorInfo(OperatorFactory.getAndMakeChild(PlanUtils.getReduceSinkDesc(
       reduceKeys, reduceValues, joinTree.getNextTag(), reduceKeys.size()), new RowSchema(outputRS.getColumnInfos()),
         child.getOp()), outputRS);
   }
@@ -2212,16 +2244,16 @@
   private exprNodeDesc genSamplePredicate(TableSample ts) {
     // ((default_sample_hashfn(cols) & Integer.MAX_VALUE) % denominator) == numerator
     exprNodeDesc numeratorExpr = new exprNodeConstantDesc(
-      TypeInfo.getPrimitiveTypeInfo(Integer.class), 
-      Integer.valueOf(ts.getNumerator()));
+        TypeInfoFactory.getPrimitiveTypeInfo(Integer.class), 
+        Integer.valueOf(ts.getNumerator()));
       
     exprNodeDesc denominatorExpr = new exprNodeConstantDesc(
-      TypeInfo.getPrimitiveTypeInfo(Integer.class), 
-      Integer.valueOf(ts.getDenominator()));
+        TypeInfoFactory.getPrimitiveTypeInfo(Integer.class), 
+        Integer.valueOf(ts.getDenominator()));
 
     exprNodeDesc intMaxExpr = new exprNodeConstantDesc(
-      TypeInfo.getPrimitiveTypeInfo(Integer.class), 
-      Integer.valueOf(Integer.MAX_VALUE));
+        TypeInfoFactory.getPrimitiveTypeInfo(Integer.class), 
+        Integer.valueOf(Integer.MAX_VALUE));
     ArrayList<exprNodeDesc> args = new ArrayList<exprNodeDesc>();
     for (String col: ts.getCols()) {
       // TODO: change type to the one in the table schema
@@ -2251,9 +2283,16 @@
     Table tab = qb.getMetaData().getSrcForAlias(alias);
 
     RowResolver rwsch = new RowResolver();
-    for (SerDeField field : tab.getFields(null)) {
-      rwsch.put(alias, field.getName(),
-                new ColumnInfo(field.getName(), new TypeInfo(tab.getSerDe(), field), false));
+    try {
+      StructObjectInspector rowObjectInspector = (StructObjectInspector)tab.getDeserializer().getObjectInspector();
+      List<? extends StructField> fields = rowObjectInspector.getAllStructFieldRefs();
+      for (int i=0; i<fields.size(); i++) {
+        rwsch.put(alias, fields.get(i).getFieldName(),
+            new ColumnInfo(fields.get(i).getFieldName(), 
+                TypeInfoUtils.getTypeInfoFromObjectInspector(fields.get(i).getFieldObjectInspector()), false));
+      }
+    } catch (SerDeException e) {
+      throw new RuntimeException(e);
     }
     // Hack!! - refactor once the metadata APIs with types are ready
     // Finally add the partitioning columns
@@ -2559,12 +2598,8 @@
               isfirst = false;
             }
 
-            tableDesc tt_desc = new tableDesc(
-                org.apache.hadoop.hive.serde.simple_meta.MetadataTypedColumnsetSerDe.class,
-                TextInputFormat.class,
-                IgnoreKeyTextOutputFormat.class,
-                Utilities.makeProperties(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, "" + Utilities.ctrlaCode,
-                                         "columns", sb.toString()));
+            tableDesc tt_desc = PlanUtils.getDefaultTableDesc(Integer.toString(Utilities.ctrlaCode),
+                                         sb.toString());
 
             // Create a file sink operator for this file name
             Operator<? extends Serializable> fs_op = OperatorFactory.get(new fileSinkDesc(taskTmpDir, tt_desc),
@@ -2701,9 +2736,9 @@
     for (int i = 0; i < children.size(); i++)
     {
       exprNodeDesc desc = children.get(i);
-      Class<?> pType = TypeInfo.generalizePrimitive(pTypes[i]);
+      Class<?> pType = ObjectInspectorUtils.generalizePrimitive(pTypes[i]);
       if (desc instanceof exprNodeNullDesc) {
-        exprNodeConstantDesc newCh = new exprNodeConstantDesc(TypeInfo.getPrimitiveTypeInfo(pType), null);
+        exprNodeConstantDesc newCh = new exprNodeConstantDesc(TypeInfoFactory.getPrimitiveTypeInfo(pType), null);
         ch.add(newCh);
       } else if (pType.isAssignableFrom(desc.getTypeInfo().getPrimitiveClass())) {
         // no type conversion needed
@@ -2722,13 +2757,13 @@
         ArrayList<exprNodeDesc> conversionArg = new ArrayList<exprNodeDesc>(1);
         conversionArg.add(desc);
         ch.add(new exprNodeFuncDesc(
-              TypeInfo.getPrimitiveTypeInfo(pType),
+              TypeInfoFactory.getPrimitiveTypeInfo(pType),
               c, m, conversionArg));
       }
     }
 
     exprNodeFuncDesc desc = new exprNodeFuncDesc(
-      TypeInfo.getPrimitiveTypeInfo(TypeInfo.generalizePrimitive(udfMethod.getReturnType())),
+      TypeInfoFactory.getPrimitiveTypeInfo(udfMethod.getReturnType()),
       FunctionRegistry.getUDFClass(udfName),
       udfMethod, ch);
     return desc;
@@ -2803,6 +2838,7 @@
         break;
       }
     }
+    assert(desc != null);
     return desc;
   }
 
@@ -2861,6 +2897,7 @@
     // return the child directly if the conversion is redundant.
     if (isRedundantConversionFunction(expr, isFunction, children)) {
       assert(children.size() == 1);
+      assert(children.get(0) != null);
       return children.get(0);
     }
     String funcText = getFunctionText(expr, isFunction);
@@ -2876,7 +2913,7 @@
       
       // Calculate TypeInfo
       String fieldNameString = (String)fieldName.getValue();
-      TypeInfo t = object.getTypeInfo().getFieldType(fieldNameString);
+      TypeInfo t = object.getTypeInfo().getStructFieldTypeInfo(fieldNameString);
       
       desc = new exprNodeFieldDesc(t, children.get(0), fieldNameString);
       
@@ -2890,13 +2927,16 @@
       }
       
       // Calculate TypeInfo
-      TypeInfo t = children.get(0).getTypeInfo().getListElementType();
+      TypeInfo t = children.get(0).getTypeInfo().getListElementTypeInfo();
       desc = new exprNodeIndexDesc(t, children.get(0), children.get(1));
     } else {
       // other operators or functions
       Class<? extends UDF> udf = FunctionRegistry.getUDFClass(funcText);
       if (udf == null) {
-        throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg((CommonTree)expr.getChild(0)));
+      	if (isFunction)
+          throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg((CommonTree)expr.getChild(0)));
+      	else
+          throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg((CommonTree)expr));
       }
       
       desc = getFuncExprNodeDesc(funcText, children);
@@ -2915,6 +2955,7 @@
         }
       }
     }
+    assert(desc != null);
     return desc;
   }
 
@@ -2927,7 +2968,7 @@
       case HiveParser.Identifier:
         // This is the case for an XPATH element (like "c" in "a.b.c.d")
         desc = new exprNodeConstantDesc(
-            TypeInfo.getPrimitiveTypeInfo(String.class), expr.getText());
+            TypeInfoFactory.getPrimitiveTypeInfo(String.class), expr.getText());
         break;
       case HiveParser.Number:
         Number v = null;
@@ -2946,6 +2987,9 @@
       case HiveParser.StringLiteral:
         desc = new exprNodeConstantDesc(String.class, BaseSemanticAnalyzer.unescapeSQLString(expr.getText()));
         break;
+      case HiveParser.TOK_CHARSETLITERAL:
+        desc = new exprNodeConstantDesc(String.class, BaseSemanticAnalyzer.charSetString(expr.getChild(0).getText(), expr.getChild(1).getText()));
+        break;
       case HiveParser.KW_TRUE:
         desc = new exprNodeConstantDesc(Boolean.class, Boolean.TRUE);
         break;

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeInfo.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeInfo.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeInfo.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeInfo.java Fri Sep 19 16:56:30 2008
@@ -1,251 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hive.ql.parse;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.hadoop.hive.serde.SerDe;
-import org.apache.hadoop.hive.serde.SerDeField;
-
-/**
- * Stores information about a type.
- * 
- * This class fixes an important problem in SerDe: SerDeField.getListElementType(), 
- * SerDeField.getMapKeyType(), and SerDeField.getMapValueType() should return a type 
- * description object, instead of the Class object, so we can support types that are 
- * not represented by a java class. 
- * 
- * The current implementation is just a simple wrapper around SerDe and SerDeField.
- * Later it might be possible to merge this class into SerDe etc.
- * 
- * Note: It may not be possible to store the Type information as a Java Class object,
- * because we support all SerDe's including those that are not using Java Reflection. 
- * 
- * 
- * We support 4 categories of types:
- * 1. Primitive objects (String, Number, etc)
- * 2. List objects (a list of objects of a single type)
- * 3. Map objects (a map from objects of one type to objects of another type)
- * 4. Struct objects
- * 
- */
-public class TypeInfo {
-
-  static enum Category {
-    UNINITIALIZED, PRIMITIVE, LIST, MAP, STRUCT
-  };
-  
-  Category category;
-  
-  // Only for primitive objects.
-  Class<?>    primitiveClass; 
-  
-  // For all other 3 categories.
-  SerDeField currentField;
-  SerDe      currentSerDe;
-  
-  /**
-   * Default constructor.
-   */
-  public TypeInfo() {
-    this.category = Category.UNINITIALIZED;
-    this.primitiveClass = null;
-    this.currentField = null;
-    this.currentSerDe = null;    
-  }
-
-  /**
-   * Default constructor.
-   */
-  public TypeInfo(Category category) {
-    this.category = category;
-    this.primitiveClass = null;
-    this.currentField = null;
-    this.currentSerDe = null;    
-  }
-
-  /**
-   * Constructor for primitive TypeInfo.
-   * @param primitiveType
-   */
-  public TypeInfo(Class<?> primitiveType) {
-    this.category = Category.PRIMITIVE;
-    this.primitiveClass = primitiveType; 
-  }
-  
-  /**
-   * Constructor for SerDe-based TypeInfo. 
-   * currentField can be null, which means the top-level field.
-   * 
-   * @param currentField   
-   * @param currentSerDe
-   */
-  public TypeInfo(SerDe currentSerDe, SerDeField currentField) {
-
-    this.currentSerDe = currentSerDe;
-    this.currentField = currentField;
-    
-    if (currentField == null) {
-      // Top level field
-      this.category = Category.STRUCT;
-    } else if (currentField.isList()) {
-      this.category = Category.LIST;
-    } else if (currentField.isMap()) {
-      this.category = Category.MAP;
-    } else if (currentField.isPrimitive()) {
-      this.category = Category.PRIMITIVE;
-      this.primitiveClass = generalizePrimitive(currentField.getType());
-      this.currentSerDe = null;
-      this.currentField = null;
-    } else {
-      this.category = Category.STRUCT;
-    }
-    
-  }
-
-  /** Only for primitive type. 
-   */
-  public Class<?> getPrimitiveClass() {
-    assert(this.category == Category.PRIMITIVE);
-    return this.primitiveClass;
-  }
-
-  /** Only for list type. 
-   */
-  public TypeInfo getListElementType() {
-    assert(this.category == Category.LIST);
-    try {
-      return new TypeInfo(this.currentSerDe, this.currentSerDe.getFieldFromExpression(this.currentField, "[0]"));
-    } catch (Exception e){
-      throw new RuntimeException(e);
-    }
-  }
-  
-  /** Only for map type.
-   */
-  public TypeInfo getMapKeyType() {
-    assert(this.category == Category.MAP);
-    return new TypeInfo(this.currentField.getMapKeyType());
-  }
-  
-  /** Only for map type.
-   */
-  public TypeInfo getMapValueType() {
-    assert(this.category == Category.MAP);
-    return new TypeInfo(this.currentField.getMapValueType());
-  }
-  
-  /** Only for Struct type.
-   */
-  public TypeInfo getFieldType(String fieldName) {
-    assert(this.category == Category.STRUCT);
-    try {
-      return new TypeInfo(this.currentSerDe, this.currentSerDe.getFieldFromExpression(this.currentField, fieldName));
-    } catch (Exception e){
-      throw new RuntimeException(e);
-    }
-  }
-  
-  /** Only for Struct type.
-   */
-  public List<TypeInfo> getAllFieldsTypes() {
-    ArrayList<TypeInfo> typeInfos = new ArrayList<TypeInfo>();
-    try { 
-      for(SerDeField field : this.currentSerDe.getFields(this.currentField)) {
-        typeInfos.add(new TypeInfo(this.currentSerDe, field));
-      }
-    } catch (Exception e){
-      throw new RuntimeException(e);
-    }
-    return typeInfos;
-  }
-  
-  @Override
-  public boolean equals(Object other) {
-    if (other.getClass() != TypeInfo.class) {
-      return false;
-    }
-    TypeInfo another = (TypeInfo)other;
-    if (another == null) return false;
-    if (this.category != another.category) return false;
-    switch(this.category) {
-      case PRIMITIVE: 
-        return this.getPrimitiveClass().equals(another.getPrimitiveClass());
-      case LIST: 
-        return this.getListElementType().equals(another.getListElementType());
-      case MAP: 
-        return this.getMapKeyType().equals(another.getMapKeyType()) 
-            && this.getMapValueType().equals(another.getMapValueType());
-      case STRUCT:
-        return this.getAllFieldsTypes().equals(another.getAllFieldsTypes());
-    }
-    return false;
-  }
-  
-  public String toString() {
-    switch(this.category) {
-      case PRIMITIVE: 
-        return this.getPrimitiveClass().toString();
-      case LIST: 
-        return "List<" + this.getListElementType().toString() + ">";
-      case MAP: 
-        return "Map<" + this.getMapKeyType().toString() + ","
-            + this.getMapValueType().toString() + ">";
-      case STRUCT:
-        return "Struct(" + this.getAllFieldsTypes().toString() + ")";
-    }
-    return "(Unknown TypeInfo)";    
-  }
-  
-  private static HashMap<Class<?>, TypeInfo> cache;
-  static {
-    cache = new HashMap<Class<?>, TypeInfo>(); 
-  }
-  
-  public static TypeInfo getPrimitiveTypeInfo(Class<?> primitiveClass) {
-    primitiveClass = generalizePrimitive(primitiveClass);
-    TypeInfo result = cache.get(primitiveClass);
-    if (result == null) {
-      result = new TypeInfo(primitiveClass);
-      cache.put(primitiveClass, result);
-    }
-    return result;
-  }
-  
-
-  public static Class<?> generalizePrimitive(Class<?> primitiveClass) {
-    if (primitiveClass == Boolean.TYPE)   primitiveClass = Boolean.class;
-    if (primitiveClass == Byte.TYPE)      primitiveClass = Byte.class; 
-    if (primitiveClass == Character.TYPE) primitiveClass = Character.class; 
-    if (primitiveClass == Short.TYPE)     primitiveClass = Short.class; 
-    if (primitiveClass == Integer.TYPE)   primitiveClass = Integer.class; 
-    if (primitiveClass == Long.TYPE)      primitiveClass = Long.class; 
-    if (primitiveClass == Float.TYPE)     primitiveClass = Float.class; 
-    if (primitiveClass == Double.TYPE)    primitiveClass = Double.class;
-    if (primitiveClass == Void.TYPE)      primitiveClass = Void.class;
-    return primitiveClass;
-  }
-  
-  public String getTypeString() {
-    // TODO: Change this to print out a better user visible string
-    return toString();
-  }
-}

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java Fri Sep 19 16:56:30 2008
@@ -21,6 +21,11 @@
 import java.util.*;
 import java.io.*;
 import org.apache.hadoop.hive.ql.exec.Operator;
+import org.apache.hadoop.hive.ql.exec.Utilities;
+import org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat;
+import org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
+import org.apache.hadoop.mapred.TextInputFormat;
 
 public class PlanUtils {
 
@@ -37,4 +42,52 @@
                           null,
                           Integer.valueOf (1));
   }
+  
+  public static tableDesc getDefaultTableDesc(String separatorCode, String columns) {
+    return new tableDesc(
+        MetadataTypedColumnsetSerDe.class,
+        TextInputFormat.class,
+        IgnoreKeyTextOutputFormat.class,
+        Utilities.makeProperties(
+            org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, separatorCode,
+            "columns", columns));    
+  }
+  public static tableDesc getDefaultTableDesc(String separatorCode) {
+    return new tableDesc(
+        MetadataTypedColumnsetSerDe.class,
+        TextInputFormat.class,
+        IgnoreKeyTextOutputFormat.class,
+        Utilities.makeProperties(
+            org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, separatorCode));    
+  }
+
+  
+  // We will make reduce key and reduce value TableDesc with configurable SerDes   
+  public static reduceSinkDesc getReduceSinkDesc(ArrayList<exprNodeDesc> keyCols,
+      ArrayList<exprNodeDesc> valueCols, int numPartitionFields) {
+     
+     return new reduceSinkDesc(keyCols, valueCols, numPartitionFields,
+         getDefaultTableDesc("" + Utilities.ctrlaCode, ObjectInspectorUtils.getIntegerCSV(keyCols.size())),
+         getDefaultTableDesc("" + Utilities.ctrlaCode, ObjectInspectorUtils.getIntegerCSV(valueCols.size())));
+  }
+  
+  // We will make reduce key and reduce value TableDesc with configurable SerDes   
+  public static reduceSinkDesc getReduceSinkDesc(ArrayList<exprNodeDesc> keyCols,
+      ArrayList<exprNodeDesc> valueCols, int tag, int numPartitionFields) {
+     
+     return new reduceSinkDesc(keyCols, valueCols, tag, numPartitionFields,
+         getDefaultTableDesc("" + Utilities.ctrlaCode, ObjectInspectorUtils.getIntegerCSV(keyCols.size())),
+         getDefaultTableDesc("" + Utilities.ctrlaCode, ObjectInspectorUtils.getIntegerCSV(valueCols.size())));
+  }
+
+  // We should read the TableDesc from gWork when it is available.   
+  public static tableDesc getReduceKeyDesc(mapredWork gWork) {
+     return getDefaultTableDesc("" + Utilities.ctrlaCode);
+  }
+
+  // We should read the TableDesc from gWork when it is available.   
+  public static tableDesc getReduceValueDesc(mapredWork gWork, int tag) {
+     return getDefaultTableDesc("" + Utilities.ctrlaCode);
+  }
+  
 }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/createTableDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/createTableDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/createTableDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/createTableDesc.java Fri Sep 19 16:56:30 2008
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Order;
 import org.apache.hadoop.hive.ql.exec.Utilities;
 
 @explain(displayName="Create Table")
@@ -33,23 +34,23 @@
   List<FieldSchema>   cols;
   List<FieldSchema>   partCols;
   List<String>        bucketCols;
-  List<String>        sortCols;
+  List<Order>         sortCols;
   int                 numBuckets;
   String              fieldDelim;
   String              collItemDelim;
   String              mapKeyDelim;
   String              lineDelim;
   String              comment;
-  boolean             isCompressed;
+  boolean             isSequenceFile;
   String              location;
   
   public createTableDesc(String tableName, boolean isExternal, 
                          List<FieldSchema> cols, List<FieldSchema> partCols,
-                         List<String> bucketCols, List<String> sortCols, 
+                         List<String> bucketCols, List<Order> sortCols, 
                          int numBuckets, String fieldDelim, 
                          String collItemDelim,
                          String mapKeyDelim, String lineDelim, 
-                         String comment, boolean isCompressed, 
+                         String comment, boolean isSequenceFile, 
                          String location) {
     this.tableName       = tableName;
     this.isExternal      = isExternal;
@@ -59,7 +60,7 @@
     this.cols            = cols;
     this.comment         = comment;
     this.fieldDelim      = fieldDelim;
-    this.isCompressed    = isCompressed;
+    this.isSequenceFile    = isSequenceFile;
     this.lineDelim       = lineDelim;
     this.location        = location;
     this.mapKeyDelim     = mapKeyDelim;
@@ -165,13 +166,13 @@
     this.comment = comment;
   }
 
-  @explain(displayName="isCompressed")
-  public boolean isCompressed() {
-    return isCompressed;
+  @explain(displayName="isSequenceFile")  
+  public boolean isSequenceFile() {
+    return isSequenceFile;
   }
 
-  public void setCompressed(boolean isCompressed) {
-    this.isCompressed = isCompressed;
+  public void setSequenceFile(boolean isSequenceFile) {
+    this.isSequenceFile = isSequenceFile;
   }
 
   @explain(displayName="location")
@@ -196,14 +197,14 @@
    * @return the sortCols
    */
   @explain(displayName="sort columns")
-  public List<String> getSortCols() {
+  public List<Order> getSortCols() {
     return sortCols;
   }
 
   /**
    * @param sortCols the sortCols to set
    */
-  public void setSortCols(List<String> sortCols) {
+  public void setSortCols(List<Order> sortCols) {
     this.sortCols = sortCols;
   }
 }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/descTableDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/descTableDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/descTableDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/descTableDesc.java Fri Sep 19 16:56:30 2008
@@ -18,9 +18,8 @@
 
 package org.apache.hadoop.hive.ql.plan;
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Serializable;
+import org.apache.hadoop.fs.Path;
 
 @explain(displayName="Describe Table")
 public class descTableDesc extends ddlDesc implements Serializable 
@@ -28,13 +27,13 @@
   private static final long serialVersionUID = 1L;
   
   String            tableName;
-  File              resFile;
+  Path              resFile;
   
   /**
    * @param resFile
    * @param tableName
    */
-  public descTableDesc(File resFile, String tableName) {
+  public descTableDesc(Path resFile, String tableName) {
     this.resFile = resFile;
     this.tableName = tableName;
   }
@@ -51,24 +50,19 @@
   /**
    * @return the resFile
    */
-  public File getResFile() {
+  public Path getResFile() {
     return resFile;
   }
 
   @explain(displayName="result file", normalExplain=false)
   public String getResFileString() {
-    try {
-      return getResFile().getCanonicalPath();
-    }
-    catch (IOException ioe) {
-      return "error";
-    }
+    return getResFile().getName();
   }
   
   /**
    * @param resFile the resFile to set
    */
-  public void setResFile(File resFile) {
+  public void setResFile(Path resFile) {
     this.resFile = resFile;
   }
 }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/explainWork.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/explainWork.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/explainWork.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/explainWork.java Fri Sep 19 16:56:30 2008
@@ -18,23 +18,23 @@
 
 package org.apache.hadoop.hive.ql.plan;
 
-import java.io.File;
 import java.io.Serializable;
 import java.util.List;
 
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.ql.exec.Task;
 
 public class explainWork implements Serializable {
   private static final long serialVersionUID = 1L;
 
-  private File resFile;
+  private Path resFile;
   private List<Task<? extends Serializable>> rootTasks;
   private String astStringTree;
   boolean extended;
   
   public explainWork() { }
   
-  public explainWork(File resFile, 
+  public explainWork(Path resFile, 
                      List<Task<? extends Serializable>> rootTasks,
                      String astStringTree,
                      boolean extended) {
@@ -44,11 +44,11 @@
     this.extended = extended;
   }
   
-  public File getResFile() {
+  public Path getResFile() {
     return resFile;
   }
   
-  public void setResFile(File resFile) {
+  public void setResFile(Path resFile) {
     this.resFile = resFile;
   }
   

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeColumnDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeColumnDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeColumnDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeColumnDesc.java Fri Sep 19 16:56:30 2008
@@ -20,7 +20,8 @@
 
 import java.io.Serializable;
 
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoFactory;
 
 public class exprNodeColumnDesc extends exprNodeDesc implements Serializable {
   private static final long serialVersionUID = 1L;
@@ -32,7 +33,7 @@
     this.column = column;
   }
   public exprNodeColumnDesc(Class<?> c, String column) {
-    super(TypeInfo.getPrimitiveTypeInfo(c));
+    super(TypeInfoFactory.getPrimitiveTypeInfo(c));
     this.column = column;
   }
   public String getColumn() {

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeConstantDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeConstantDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeConstantDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeConstantDesc.java Fri Sep 19 16:56:30 2008
@@ -20,7 +20,9 @@
 
 import java.io.Serializable;
 
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoFactory;
+
 
 public class exprNodeConstantDesc extends exprNodeDesc implements Serializable {
   private static final long serialVersionUID = 1L;
@@ -32,7 +34,7 @@
     this.value = value;
   }
   public exprNodeConstantDesc(Class<?> c, Object value) {
-    this(TypeInfo.getPrimitiveTypeInfo(c), value);
+    this(TypeInfoFactory.getPrimitiveTypeInfo(c), value);
   }
   public exprNodeConstantDesc(Object value) {
     this(value.getClass(), value);

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeDesc.java Fri Sep 19 16:56:30 2008
@@ -20,15 +20,19 @@
 
 import java.io.Serializable;
 
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
 
 public class exprNodeDesc implements Serializable {  
   private static final long serialVersionUID = 1L;
-  transient TypeInfo typeInfo;
+  TypeInfo typeInfo;
   
   public exprNodeDesc() {}
   public exprNodeDesc(TypeInfo typeInfo) {
     this.typeInfo = typeInfo;
+    if (typeInfo == null) {
+      throw new RuntimeException("typeInfo cannot be null!");
+    }
   }
   
   public TypeInfo getTypeInfo() {
@@ -45,6 +49,6 @@
   
   @explain(displayName="type")
   public String getTypeString() {
-    return typeInfo.getTypeString();
+    return typeInfo.getTypeName();
   }
 }

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFieldDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFieldDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFieldDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFieldDesc.java Fri Sep 19 16:56:30 2008
@@ -19,8 +19,8 @@
 package org.apache.hadoop.hive.ql.plan;
 
 import java.io.Serializable;
-
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
+
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
 
 public class exprNodeFieldDesc extends exprNodeDesc implements Serializable {
   private static final long serialVersionUID = 1L;

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFuncDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFuncDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFuncDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeFuncDesc.java Fri Sep 19 16:56:30 2008
@@ -24,9 +24,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
 import org.apache.hadoop.hive.ql.exec.FunctionInfo;
 import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
 
 /**
  * The reason that we have to store UDFClass as well as UDFMethod is because

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeIndexDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeIndexDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeIndexDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeIndexDesc.java Fri Sep 19 16:56:30 2008
@@ -19,8 +19,9 @@
 package org.apache.hadoop.hive.ql.plan;
 
 import java.io.Serializable;
+
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfo;
 
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
 
 public class exprNodeIndexDesc extends exprNodeDesc implements Serializable {
   private static final long serialVersionUID = 1L;
@@ -33,6 +34,11 @@
     this.desc = desc;
     this.index = index;    
   }
+  public exprNodeIndexDesc(exprNodeDesc desc, exprNodeDesc index) {
+    super(desc.getTypeInfo().getListElementTypeInfo());
+    this.desc = desc;
+    this.index = index;    
+  }
   
   public exprNodeDesc getDesc() {
     return this.desc;

Modified: hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeNullDesc.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeNullDesc.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeNullDesc.java (original)
+++ hadoop/core/trunk/src/contrib/hive/ql/src/java/org/apache/hadoop/hive/ql/plan/exprNodeNullDesc.java Fri Sep 19 16:56:30 2008
@@ -20,14 +20,14 @@
 
 import java.io.Serializable;
 
-import org.apache.hadoop.hive.ql.parse.TypeInfo;
+import org.apache.hadoop.hive.ql.typeinfo.TypeInfoFactory;
 
 public class exprNodeNullDesc extends exprNodeDesc implements Serializable {
   
   private static final long serialVersionUID = 1L;
 
   public exprNodeNullDesc() {
-    super(new TypeInfo(Void.class));
+    super(TypeInfoFactory.getPrimitiveTypeInfo(Void.class));
   }
 
   public Object getValue() {



Mime
View raw message