forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#39 from marmbrus/lateralView
Add support for lateral views, TGFs and Hive UDTFs
- Loading branch information
Showing
20 changed files
with
570 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package catalyst | ||
package execution | ||
|
||
import catalyst.expressions._ | ||
import catalyst.types._ | ||
|
||
/** | ||
* Applies a [[catalyst.expressions.Generator Generator]] to a stream of input rows, combining the | ||
* output of each into a new stream of rows. This operation is similar to a `flatMap` in functional | ||
* programming with one important additional feature, which allows the input rows to be joined with | ||
* their output. | ||
* @param join when true, each output row is implicitly joined with the input tuple that produced | ||
* it. | ||
* @param outer when true, each input row will be output at least once, even if the output of the | ||
* given `generator` is empty. `outer` has no effect when `join` is false. | ||
*/ | ||
case class Generate( | ||
generator: Generator, | ||
join: Boolean, | ||
outer: Boolean, | ||
child: SharkPlan) | ||
extends UnaryNode { | ||
|
||
def output = | ||
if (join) child.output ++ generator.output else generator.output | ||
|
||
def execute() = { | ||
if (join) { | ||
val outerNulls = Seq.fill(generator.output.size)(null) | ||
child.execute().mapPartitions { iter => | ||
iter.flatMap {row => | ||
val outputRows = generator(row) | ||
if (outer && outputRows.isEmpty) { | ||
new GenericRow(row ++ outerNulls) :: Nil | ||
} else { | ||
outputRows.map(or => new GenericRow(row ++ or)) | ||
} | ||
} | ||
} | ||
} else { | ||
child.execute().mapPartitions(iter => iter.flatMap(generator)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.