Package com.sap.hadoop.windowing.query2.definition

Examples of com.sap.hadoop.windowing.query2.definition.OrderDef


    }

    @Override
    public QueryInputSpec next()
    {
      QueryInputSpec curr = nextInput;
      if ( curr instanceof TableFuncSpec)
      {
        TableFuncSpec tFunc = (TableFuncSpec) curr;
        nextInput = tFunc.getInput();
      }
View Full Code Here


    @Override
    public boolean hasNext()
    {
      if ( qSpecIt.hasNext())
      {
        QueryInputSpec iSpec = qSpecIt.next();
        if ( iSpec instanceof TableFuncSpec)
        {
          nextInput = (TableFuncSpec) iSpec;
          return true;
        }
View Full Code Here

  }
 
  public static void validateOutputSpec(QueryDef qDef) throws WindowingException
  {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QueryOutputSpec spec = qDef.getSpec().getOutput();
   
    // ensure outputPath is specified. It is optional in grammar because it is not required in Hive mode.
    if ( spec == null || spec.getPath() == null )
    {
      throw new WindowingException("Query doesn't contain an output Path for results");
    }
   
    // if tableName is specified; validate it exists
    Table oTbl = null;
    if ( spec.getHiveTable() != null )
    {
      oTbl = getHiveTableDetails(tInfo.getHiveCfg(), spec.getHiveTable(), qDef.getInput().getHiveTableSpec());
    }
   
    // validate serDeClass
    if ( spec.getSerDeClass() == null )
    {
      if ( oTbl != null && oTbl.getSd().getSerdeInfo().isSetSerializationLib() )
      {
        spec.setSerDeClass(oTbl.getSd().getSerdeInfo().getSerializationLib());
        if ( oTbl.getSd().getSerdeInfo().isSetParameters() )
        {
          Iterator<Map.Entry<String, String>> props = oTbl.getSd().getSerdeInfo().getParameters().entrySet().iterator();
          while(props.hasNext())
          {
            Map.Entry<String, String> e = props.next();
            spec.addSerdeProperty(e.getKey(), e.getValue());
          }
        }
      }
      else
      {
        spec.setSerDeClass(com.sap.hadoop.windowing.Constants.DEFAULT_SERDE_CLASSNAME);
        spec.addSerdeProperty(org.apache.hadoop.hive.serde.Constants.FIELD_DELIM, ",");
      }
    }
   
    try
    {
      Class.forName(spec.getSerDeClass());
    }
    catch(Throwable t)
    {
      throw new WindowingException(sprintf("Unknown SerDe Class %s", spec.getSerDeClass()), t);
    }
   
    // validate outputFormat
    if ( spec.getOutputFormatClass() == null )
    {
      if ( oTbl != null )
      {
        spec.setOutputFormatClass(oTbl.getSd().getOutputFormat());
      }
      else
      {
        spec.setOutputFormatClass(Constants.DEFAULT_OUTPUTFORMAT_CLASSNAME);
      }
    }
    try
    {
      Class.forName(spec.getOutputFormatClass());
    }
    catch(Throwable t)
    {
      throw new WindowingException(
        sprintf("Unknown OutputFormat Class %s", spec.getOutputFormatClass()), t);
    }
   
    // ensure user has not specified a FormatClass
    if ( spec.getRecordWriterClass() != null )
    {
      throw new WindowingException("Illegal Output Spec: RecordWriter class not valid in MR mode");
    }
   
  }
View Full Code Here

    this.orderString = orderString;
  }

  public String getOutputPath()
  {
    QueryOutputSpec qOutSpec = qdef.getOutput().getOutputSpec();
    outputPath = qOutSpec.getPath();
    return outputPath;
  }
View Full Code Here

public class WhereTranslation
{
  public static void translate(QueryDef qDef) throws WindowingException
  {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QuerySpec spec = qDef.getSpec();
   
    ASTNode wExpr = spec.getWhereExpr();
   
    if ( wExpr == null ) return;
   
    WhereDef whDef = new WhereDef();
    whDef.setExpression(wExpr);
View Full Code Here

public class InputTranslation
{
 
  public static void translate(QueryDef qDef) throws WindowingException
  {
    QuerySpec spec = qDef.getSpec();
   
    /*
     * validate that input chain ends in a Hive Query or TAble.
     */
    if ( !spec.getInput().sourcedFromHive() )
    {
      throw new WindowingException("Translation not supported for HdfsLocation based queries");
    }
   
    EnsureTableFunctionInQuery.execute(qDef);
View Full Code Here

    return ParseUtils.parse(query);
  }
 
  public QueryDef translate(String query) throws WindowingException
  {
    QuerySpec qSpec = parse(query);
    return translator.translate(qSpec, this);
  }
View Full Code Here

    {
     
      nodes = new CommonTreeNodeStream(t);
      nodes.setTokenStream(tokens);
      qSpecBldr = new QSpecBuilder2(nodes);
      SelectSpec selectSpec = qSpecBldr.select();
 
      err = qSpecBldr.getWindowingParseErrors();
      if ( err != null )
      {
        throw new WindowingException(err);
View Full Code Here

  {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QueryInputDef iDef = qDef.getInput();
    InputInfo iInfo = tInfo.getInputInfo(iDef);
    SelectDef selectDef = qDef.getSelectList();
    SelectSpec selectSpec = qDef.getSpec().getSelectList();
    Iterator<Object> selectExprsAndAliases = selectSpec.getColumnListAndAlias();
    int i = 0;
    ColumnDef cDef = null;
   
   
    while(selectExprsAndAliases.hasNext())
View Full Code Here

    public QueryInputSpec next()
    {
      QueryInputSpec curr = nextInput;
      if ( curr instanceof TableFuncSpec)
      {
        TableFuncSpec tFunc = (TableFuncSpec) curr;
        nextInput = tFunc.getInput();
      }
      else
      {
        nextInput = null;
      }
View Full Code Here

TOP

Related Classes of com.sap.hadoop.windowing.query2.definition.OrderDef

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