-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Schema error: No field named mytable."A". when table is named "MyTable"
#6790
Comments
this is related with #6681. During the process of solving this problem, I encountered some difficulties, but I am working hard to resolve them. |
I also hit this same error with some of the clickbench queries. I think this was one: SELECT "RegionID", COUNT(DISTINCT "UserID") AS u FROM hits GROUP BY "RegionID" ORDER BY u DESC LIMIT 10; I hope to find time to work on this issue later in the week if you haven't had a chance @jackwener |
Thank you @jackwener |
I have been quite busy lately, and today a newcomer @YjyJeff in the community encountered the same issue and submitted a PR #6862 related to it. So I took some time to systematically analyze this problem and help others in the community better understand it. This problem is caused by #6595 directly. Although the idea of #6595 is right, but we cannot change so for the time being. Because it will expose the current design problem ( schema will be change in optimization). Let me have explain this problem:
if we use original schema: schema still is so, if we recompute new schema, it will cause BUT, alias can't avoid this corner case: #6595 (comment) so, I try to resolve it by add a so I think a better temporary method is to revert #6595 Let me talk about more. In my opinion, it is unnecessary to keep
So, keep Why we need to keep Based on my guess, the reason may be that we need to ensure the This involves a design problem. we shouldn't use Many systems in the industry have adopted this design, like spark, impala, doris... such as spark case class AttributeReference(
name: String,
datatype: DataType,
nullable: Boolean = true,
override val metadata: Metadata = Metadata.empty)(
val exprId: ExprId = NamedExpression.newExprId,
val qualifier: Seq[String] = Seq.empty[String])
extends Attribute with Unevaluable
/**
* Returns true iff the expression id is the same for both attributes.
*/
def sameRef(other: AttributeReference): Boolean = this.exprId == other.exprId |
I believe this is also what Postgres does (refers to columns by id, rather than a name) Also, interestingly, this is what DataFusion
I somehow feel this should be fixable with
This is a good point
In my opinion, the type (other than nullable) should never change after we do the Analysis phase. Otherwise we could end up getting to the physical expressions and not having the types line up |
🤔 yeah it is the approach that seems to make the most sense from an incremental sense, but I trust you if you say we can't make it work in practice... @jackwener do you think there is a good ticket that covers this issue adequately ? Your description in #6790 (comment) is really nicely done, and I think it will likely get lost in this PR if we don't pull it into a ticket |
* Field not found, releated apache/datafusion#6790
* Field not found, releated apache/datafusion#6790
Describe the bug
A query is failing that it can't find a column which exists
This was reported by a customer of IOx
To Reproduce
DataFusion CLI v27.0.0
Expected behavior
The query should plan successfully (but return no rows)
Additional context
The query works fine in version
26.0.0
👍Also if we remove the distinct the query also works:
The text was updated successfully, but these errors were encountered: