Generator Contract — Expressions to Generate Zero Or More Rows (aka Lateral Views)
Generator
is a contract for Catalyst expressions that can produce zero or more rows given a single input row.
Note
|
Generator corresponds to SQL’s LATERAL VIEW.
|
dataType
in Generator
is simply an ArrayType of elementSchema.
Generator
supports Java code generation (aka whole-stage codegen) conditionally, i.e. only when a physical operator is not marked as CodegenFallback.
Generator
uses terminate
to inform that there are no more rows to process, clean up code, and additional rows can be made here.
1 2 3 4 5 |
terminate(): TraversableOnce[InternalRow] = Nil |
Name | Description | ||||
---|---|---|---|---|---|
Corresponds to |
|||||
Represents an unresolved generator. Created when
|
|||||
Used exclusively in the deprecated |
Note
|
You can only have one generator per select clause that is enforced by ExtractGenerator logical evaluation rule, e.g.
If you want to have more than one generator in a structured query you should use
|
Generator Contract
1 2 3 4 5 6 7 8 9 10 11 |
package org.apache.spark.sql.catalyst.expressions trait Generator extends Expression { // only required methods that have no implementation def elementSchema: StructType def eval(input: InternalRow): TraversableOnce[InternalRow] } |
Method | Description |
---|---|
Schema of the elements to be generated |
|