-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds parsing and modeling for INSERT INTO <table name>
#1621
base: prep-v0_14_10
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
group=org.partiql | ||
version=0.14.9 | ||
version=0.14.10 | ||
|
||
ossrhUsername=EMPTY | ||
ossrhPassword=EMPTY | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.partiql.lang.eval | ||
|
||
/** | ||
* Represents a namespaced global binding. | ||
* @property parts a collection of the parts of the identifier. | ||
*/ | ||
data class BindingId( | ||
val parts: List<BindingName> | ||
) : Iterable<BindingName> { | ||
|
||
init { | ||
assert(parts.any()) | ||
} | ||
|
||
constructor(vararg names: BindingName) : this(names.toList()) | ||
|
||
override fun iterator(): Iterator<BindingName> { | ||
return parts.iterator() | ||
} | ||
|
||
override fun toString(): String { | ||
return when (this.parts.size > 1) { | ||
true -> parts.joinToString(".") | ||
false -> parts[0].toString() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.partiql.lang.planner | ||
|
||
import org.partiql.lang.eval.BindingCase | ||
import org.partiql.lang.eval.BindingId | ||
import org.partiql.lang.eval.BindingName | ||
|
||
/** | ||
|
@@ -17,6 +18,21 @@ sealed class GlobalResolutionResult { | |
*/ | ||
data class GlobalVariable(val uniqueId: String) : GlobalResolutionResult() | ||
|
||
/** | ||
* A success case. Refers to a variable that is contained within a namespace (AKA catalog/schema). | ||
*/ | ||
abstract class NamespacedVariable( | ||
val uniqueId: String | ||
) : GlobalResolutionResult() { | ||
/** | ||
* When attempting to resolve a qualified identifier, say `FROM cat1.schema1.table1.attr1.attr2`, the [GlobalVariableResolver] | ||
* _may_ resolve only the first few steps of the identifier, say `cat1.schema1.table1`. Therefore, it must | ||
* return the resolved [uniqueId] (say `cat1:::schema1:::table1`) and the remaining steps `attr1.attr2` in order for the planner | ||
* to convert these to path expressions. | ||
*/ | ||
abstract fun getRemainingSteps(): List<BindingName> | ||
Comment on lines
+27
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO this might be a little too forward thinking... i.e. trying to design for a future we know little about. Or is there more to this than I am aware of? In my case, all parts of a table identifier will be completely resolved or we will abort w/undefined table error. This might make sense in the event that we have only part of the schema... but that is not in my foreseeable future. I suggest dropping this. If this is dropped, I don't think we need a distinction between a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking again about this... was the intention to handle the scenario when some of the parts of the qualified identifier could be resolved but others not? I guess I'm not 100% sure I understand the intent here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that is the intention. In the This is something that has been added to |
||
} | ||
|
||
/** A failure case, indicates that resolution did not match any variable. */ | ||
object Undefined : GlobalResolutionResult() | ||
} | ||
|
@@ -56,6 +72,19 @@ fun interface GlobalVariableResolver { | |
*/ | ||
fun resolveGlobal(bindingName: BindingName): GlobalResolutionResult | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can drop this--it is redundant when you have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For backwards compatibility purposes, when adding new APIs, we've been adding default implementations that "may" utilize existing implemented methods, so that users who don't want to update their code don't have to. That being said, you're the only customer here, so it's up to you. |
||
|
||
/** | ||
* Resolves a potentially qualified [BindingId] in the database environment. | ||
* By default, if the [bindingId] does not have a qualified identifier passed to it, it will resolve using just | ||
* the unqualified identifier. If it is qualified, it will return a [GlobalResolutionResult.Undefined]. | ||
*/ | ||
fun resolveGlobal(bindingId: BindingId): GlobalResolutionResult { | ||
val parts = bindingId.parts | ||
if (parts.size == 1) { | ||
return resolveGlobal(parts.last()) | ||
} | ||
return GlobalResolutionResult.Undefined | ||
} | ||
|
||
companion object { | ||
|
||
val EMPTY = GlobalVariableResolver { GlobalResolutionResult.Undefined } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A change I've been wanting to make forever is to make
uniqueId
here anIonElement
so we can put arbitrary Ion data here instead of having to "abuse" this field by putting Ion-text here instead. I'll leave a note in the main PIG domain where we need to change this as well.... EDIT: github won't let me comment there--to do this we would also need to changepartiql_logical_resolved.expr.global_id.unique_id
to theion
type.Since we're breaking this API anyway, now might be a good time to do that as well...