Almost always, the “prefix” part is almost always the table alias, and 
therefore has length 1.

The exception is that if you use a qualified name schema.table or 
catalog.schema.table in the FROM clause you are allowed to use schema.table or 
catalog.schema.table as the qualifier, and therefore the prefix will have 
length 2 or 3.

In your case,

  select "schema"."table"."column" from “table"

you are not allowed to qualify with “schema”.”table” because you only wrote 
“table”, not “schema”.’table” in the FROM clause. So, the validator is just 
about to tell you that your query is invalid. Which it is.

Frankly I think it’s a dumb idea to qualify column names with with schema.table 
or catalog.schema.table and I wish people (and tools) didn’t do it. We have to 
support it because it is standard.

Julian



> On Jul 12, 2017, at 12:08 PM, Zain Humayun <[email protected]> 
> wrote:
> 
> Hi,
> 
> I need find the fully qualified name of a SqlIdentifier in SqlValidatorImpl, 
> and I was wondering why in a query of the form
> 
> select "schema"."table"."column" from "table"
> 
> calling scope.fullyQualify() on the SqlIdentifier "schema"."table"."column" 
> would produce a prefix list of ["table", "column"] and a suffix list of [ ]. 
> In contrast calling fullyQualify in the query
> 
> select "table"."column" from "table" 
> 
> will produce a prefix list of ["table"] and a suffix list of ["column"]. I'm 
> wondering what the prefix and suffix list actually stand for, and why fully 
> qualifying with the schema in the identifier causes the above behavior. 
> 
> Thanks,Zain. 

Reply via email to