[ 
https://issues.apache.org/jira/browse/CALCITE-1666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15895006#comment-15895006
 ] 

Julian Hyde commented on CALCITE-1666:
--------------------------------------

[~kliew], I reviewed, and it looks great. Really good test coverage, nice clean 
code. Only cosmetic issues to fix:
* Can you change method javadoc comments to 3rd person declarative (e.g. prefer 
"Gets the label" to "Get the label");
* Remove the 3 TODOs you added. Either fix the problem, or log a jira case, or 
remove the comment.
* There is one checkstyle exception.

I thought that {{getExtendedColumns}} was a bit easier to understand when I 
added a method to transform the list of alternating names and types into a list 
of pairs. But it's up to you whether you take that change:

{code}
  public static List<RelDataTypeField> getExtendedColumns(
      SqlValidator validator, SqlValidatorTable table, SqlNodeList 
extendedColumns) {
    final ImmutableList.Builder<RelDataTypeField> extendedFields = 
ImmutableList.builder();
    final ExtensibleTable extTable = table.unwrap(ExtensibleTable.class);
    int extendedFieldOffset =
        extTable == null
            ? table.getRowType().getFieldCount()
            : extTable.getExtendedColumnOffset();
    for (Pair<SqlIdentifier, SqlDataTypeSpec> pair : pairs(extendedColumns)) {
      final SqlIdentifier identifier = pair.left;
      final SqlDataTypeSpec type = pair.right;
      extendedFields.add(
          new RelDataTypeFieldImpl(identifier.getSimple(),
              extendedFieldOffset++,
              type.deriveType(validator)));
    }
    return extendedFields.build();
  }

  /** Converts a list of extended columns
   * (of the form [name0, type0, name1, type1, ...])
   * into a list of (name, type) pairs. */
  private static List<Pair<SqlIdentifier, SqlDataTypeSpec>> pairs(
      SqlNodeList extendedColumns) {
    final List list = extendedColumns.getList();
    //noinspection unchecked
    return Pair.zip(Util.quotientList(list, 2, 0),
        Util.quotientList(list, 2, 1));
  }
{code}

> Support for modifiable views with extended columns
> --------------------------------------------------
>
>                 Key: CALCITE-1666
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1666
>             Project: Calcite
>          Issue Type: Improvement
>    Affects Versions: 1.11.0
>            Reporter: Kevin Liew
>            Assignee: Julian Hyde
>              Labels: validator, view
>
> The changes for this PR is to:
> - propagate extended columns (already parsed into namespaces in the 
> validator) through to the planner
> - validate {{INSERT}} and {{UPDATE}} operations against the constraints of 
> the modifiable view
> [~maryannxue], [~rajeshbabu], [~jamestaylor]



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to