Option 6, “system” columns. Similar behavior to Oracle’s ROWID column:

select * from emp; # yields EMP, DEPTNO, NAME
select rowid, * from emp; # yields ROWID, EMPNO, DEPTNO, NAME

Defined by SqlToRelConverter.getSystemFields(). These are fields that are 
present on every table. EMP and DEPT cannot have different system columns.

Julian


> On Sep 8, 2017, at 10:45 AM, Vladimir Sitnikov <[email protected]> 
> wrote:
> 
> Hi,
> 
> I want to have a table with optional columns. It should be possible to
> select the columns by name, yet the columns should not appear in "select *".
> 
> I see the following options:
> 1) Add a record column with StructKind.PEEK_FIELDS_NO_EXPAND. It does not
> work for me since "select *" is expanded into all the column names
> (including the record), and Avatica just does not support structs.
> On top of that, I do not want to mess with those records during "table
> enumeration" (e.g. CALCITE-1890)
> 
> 2) _extra magical column. It seems to be deprecated (it does not work, and
> it is quite similar to DynamicStar)
> 
> 3) DynamicStar does not allow to specify different data types for the
> "generated" columns
> 
> 4) "select ... from emp extend (ab int)". It is a lot less usable since
> selecting a column would require to alter the SQL in multiple places
> (select clause, from clause)
> 
> 5) I've identified that there's a notion
> of org.apache.calcite.schema.Table#isRolledUp. It was added for a quite
> different purpose, however "rolled up" columns are hidden from "expandStar".
> However: I think isRolledUp implementation is somewhat broken. It does not
> work in case of nested schemas and/or tables with the same name in
> different schemas.
> 
> The implementation of isRolledUp seems to be odd to me. It tries to "find a
> table somehow", however I think the more "proper" way would be to apply
> some Namespace / Scope magic.
> 
> I'm a bit puzzled, and now I consider creating my own Calcite build that
> would just skip columns staring from "calcite.hidden:"
> 
> Vladimir

Reply via email to