-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for create table statement in planner
- Loading branch information
Showing
23 changed files
with
2,132 additions
and
132 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
51 changes: 51 additions & 0 deletions
51
partiql-planner/src/main/kotlin/org/partiql/planner/internal/DdlField.kt
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,51 @@ | ||
package org.partiql.planner.internal | ||
|
||
import org.partiql.planner.internal.ir.Statement | ||
import org.partiql.planner.internal.ir.statementDDLAttribute | ||
import org.partiql.planner.internal.typer.CompilerType | ||
import org.partiql.spi.catalog.Identifier | ||
import org.partiql.types.Field | ||
import org.partiql.types.PType | ||
import org.partiql.types.shape.PShape | ||
|
||
/** | ||
* An implementation for [Field] that is used by DDL | ||
* to hold additional information in the struct field. | ||
* It is identical to [Statement.DDL.Attribute] | ||
*/ | ||
internal data class DdlField( | ||
val name: Identifier, | ||
val type: PShape, | ||
val isNullable: Boolean, | ||
val isOptional: Boolean, | ||
val constraints: List<Statement.DDL.Constraint>, | ||
val isPrimaryKey: Boolean, | ||
val isUnique: Boolean, | ||
val comment: String? | ||
) : Field { | ||
|
||
override fun getName(): String { | ||
return name.getIdentifier().getText() | ||
} | ||
|
||
override fun getType(): PType { | ||
return type | ||
} | ||
|
||
fun toAttr() = | ||
statementDDLAttribute( | ||
this.name, | ||
this.type, | ||
this.isNullable, | ||
this.isOptional, | ||
this.isPrimaryKey, | ||
this.isUnique, | ||
this.constraints, | ||
this.comment | ||
) | ||
|
||
companion object { | ||
fun fromAttr(attr: Statement.DDL.Attribute): DdlField = | ||
DdlField(attr.name, attr.type, attr.isNullable, attr.isOptional, attr.constraints, attr.isPrimaryKey, attr.isUnique, attr.comment) | ||
} | ||
} |
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
Oops, something went wrong.