All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ps.odps-mapred-bridge.0.51.5-public.source-code.stream.vm Maven / Gradle / Ivy

There is a newer version: 0.52.1-public
Show newest version
## Hate the indentation issue! http://wiki.apache.org/velocity/VelocityWhitespaceGobbling
## macro collist: generate comma seperated column list, with label prefix if $withLabel is true
#macro(collist $tableInfo $prefix)
#foreach($col in ${tableInfo.Cols})
#if(${prefix})${prefix}#end${col}#if(${foreach.hasNext}),#end
#end ## end foreach
#end ## collist macro
#macro(selist $tableInfo $aslist)
#foreach($col in ${tableInfo.Cols})
${col}#if(${aslist}) as ${aslist[${foreach.index}]}#end#if(${foreach.hasNext}),#end
#end ## end foreach
#end ## selist macro
#macro(tblname $tableInfo)
#if(${tableInfo.ProjectName})${tableInfo.ProjectName}.#end${tableInfo.TableName}
#end ## selist tblname
## macro outputColsJoined: joined output columns.
#macro(outputColsJoined)
#if(${ctx.isNilOutput()})nil#else
#foreach($output_table in ${ctx.OutputTableInfos})
#if(${ctx.multiInsert()})
#if(!${ctx.mapOnly()})
#collist($output_table "")#break
#else
#collist($output_table "${output_table.Label}_")
#end
#else
#collist($output_table)
#end
#if(${foreach.hasNext})#if(${ctx.mapOnly()}),#end#end
#end
#if(${ctx.multiInsert()}),${ctx.MultidestLabel}#end ##
#end
#end ## outputColsJoined macro
## macro: inputColsJoined
#macro(inputColsJoined)
#if(${ctx.isNoInputTableInfos()})''
#else
#foreach($input_table in ${ctx.InputTableInfos})
#collist($input_table)#break
#end#end
#end ## inputColsJoined macro
## macro partfilter
#macro(partfilter $tableInfo)
#foreach ($entry in ${tableInfo.PartSpec.entrySet()})
${entry.Key} = "${entry.Value}" #if(${foreach.hasNext}) AND #end
#end##
#end##

$!{ctx.functionCreateText}
@sub_query_mapper :=
    select * FROM (
    #foreach ( $input_table in ${ctx.InputTableInfos} )
        FROM (SELECT * FROM #tblname($input_table)
                #if (${input_table.PartSpec} && ${input_table.PartSpec.size()} > 0)
                WHERE #partfilter($input_table)
                #end##
        )
        MAP #collist($input_table) $!{ctx.mapInputSeparator}
        USING '$!{ctx.MapStreamProcessor}'
        #if(!${ctx.mapOnly()})
        AS ${ctx.IntermediateColsJoinedMapOut} $!{ctx.mapOutputSeparator}
        #else
        AS #outputColsJoined() $!{ctx.mapOutputSeparator}
        #end##
        #if(${foreach.hasNext})UNION ALL
        #end##
    #end##
    #if(${ctx.isNoInputTableInfos()})
        FROM (select _c from values('') _t (_c) where false)
        MAP '' $!{ctx.mapInputSeparator}
        USING '$!{ctx.MapStreamProcessor}'
        #if(!${ctx.mapOnly()})
        AS ${ctx.IntermediateColsJoinedMapOut} $!{ctx.mapOutputSeparator}
        #else
        AS #outputColsJoined() $!{ctx.mapOutputSeparator}
        #end##
    #end
    ) open_mr_alias1
#if(!${ctx.mapOnly()})
DISTRIBUTE BY ${ctx.PartitionColsJoined} SORT BY ${ctx.SortColsJoined}
#end
;
#if(!${ctx.mapOnly()})

@sub_query_reducer :=
    REDUCE ${ctx.IntermediateColsJoined} $!{ctx.reduceInputSeparator}
    USING '$!{ctx.ReduceStreamProcessor}'
    AS #outputColsJoined() $!{ctx.reduceOutputSeparator}
    FROM @sub_query_mapper;
#end##

#if(!${ctx.isNilOutput()})
#foreach($output_table in ${ctx.OutputTableInfos})
INSERT#if(${ctx.isOutputOverwrite()}) OVERWRITE#else INTO#end TABLE #tblname($output_table)
#if (${output_table.PartSpec} && ${output_table.PartSpec.size()} > 0)
PARTITION(#foreach ($entry in ${output_table.PartSpec.entrySet()}) ${entry.Key} = "${entry.Value}" #if(${foreach.hasNext}),#end#end)
#end
#if(${ctx.multiInsert()})
#if(!${ctx.mapOnly()})
SELECT #collist($output_table "")
#else
SELECT #collist($output_table "${output_table.Label}_") 
#end
WHERE ${ctx.MultidestLabel} = "${output_table.Label}"
#else
SELECT #collist($output_table) 
#end	
#end
#else
SELECT *
#end
#if(!${ctx.mapOnly()})
from @sub_query_reducer;
#else
from @sub_query_mapper;
#end##




© 2015 - 2025 Weber Informatics LLC | Privacy Policy