Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5984

Cannot fully disable trimming unused fields using Calcite configs

    XMLWordPrintableJSON

Details

    Description

      In Prepare#prepareSql there are 2 instances of trimming unused fields

      1. Prepare#trimUnusedFields called here 

      // Trim unused fields.
      root = trimUnusedFields(root); 

      2. TrimFieldsProgram called here within

      root = optimize(root, getMaterializations(), getLattices());
      

      I want to turn of the field trimming due to a personalisation I'm implementing to scan a specific API, which I would think is possible using SqlConverter.Config

      I attempted to disable the trimming using hooks [PROGRAM, SQL2REL_CONVERTER_CONFIG_BUILDER], which succeeded to remove the trimming program, yet on Prepare#trimUnusedFields

      // code placehprotected RelRoot trimUnusedFields(RelRoot root) {
        final SqlToRelConverter.Config config = SqlToRelConverter.config()
            .withTrimUnusedFields(shouldTrim(root.rel))
            .withExpand(THREAD_EXPAND.get())
            .withInSubQueryThreshold(castNonNull(THREAD_INSUBQUERY_THRESHOLD.get()));
        final SqlToRelConverter converter =
            getSqlToRelConverter(getSqlValidator(), catalogReader, config);
        final boolean ordered = !root.collation.getFieldCollations().isEmpty();
        final boolean dml = SqlKind.DML.contains(root.kind);
        return root.withRel(converter.trimUnusedFields(dml || ordered, root.rel));
      }
      

      The config passed (and edited by the hook) gets overwritten and only shouldTrim(root.rel) can enable/disable trimming, I would expect this to happen iff the config withTrimUnusedFields is only set to true.

      Is this the intended behaviour? Any help is appreciated, thanks.

      Attachments

        Activity

          People

            wegdanghazi Wegdan Ghazi
            wegdanghazi Wegdan Ghazi
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: