ompute.logical-plan.0.2.1.source-code.LogicalPlan.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logical-plan Show documentation
Show all versions of logical-plan Show documentation
JVM query engine based on Apache Arrow
package org.ballistacompute.logical
import org.ballistacompute.datatypes.Schema
/**
* A logical plan represents a data transformation or action that returns a relation (a set of tuples).
*/
interface LogicalPlan {
/**
* Returns the schema of the data that will be produced by this logical plan.
*/
fun schema(): Schema
/**
* Returns the children (inputs) of this logical plan. This method is used to enable use of the
* visitor pattern to walk a query tree.
*/
fun children(): List
fun pretty(): String {
return format(this)
}
}
/** Format a logical plan in human-readable form */
fun format(plan: LogicalPlan, indent: Int = 0): String {
val b = StringBuilder()
0.until(indent).forEach { b.append("\t") }
b.append(plan.toString()).append("\n")
plan.children().forEach { b.append(format(it, indent+1)) }
return b.toString()
}