Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-1323

Add support for pushdown of non-literal procedure parameter expressions.

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 13.0
    • 7.2
    • Query Engine
    • None

      We are forcing all push-down procedure arguments to be literals (for simplicity), when all expressions should be allowed.

            [TEIID-1323] Add support for pushdown of non-literal procedure parameter expressions.

            It is possible that given TEIID-5821 there could be a need for procedure parameter pushdown with an expression needs to be supported as well. This is a long standing issue that was only partially addressed previously. To fully address we need a new capability and a breaking method change to SQLConversionVisitor - it's possible to backport without the breaking change though.

            Steven Hawkins added a comment - It is possible that given TEIID-5821 there could be a need for procedure parameter pushdown with an expression needs to be supported as well. This is a long standing issue that was only partially addressed previously. To fully address we need a new capability and a breaking method change to SQLConversionVisitor - it's possible to backport without the breaking change though.

            Sources (such as SQL Server) and individual procedures (JDBC direct execution assumes ? parameter sql that requires literal binding) expect only literal parameters. We cannot generally push non-literals unless we add a capability and possibly extension metadata on procedures - alternatively all procedure handling on sources that do support non-literal arguments would need modified.

            At this point it seems sufficient to just allow this at a translator language level and mark the issue as partially completed. This can be revisited if critical for performance or if it's the only way to address a particular case.

            Steven Hawkins added a comment - Sources (such as SQL Server) and individual procedures (JDBC direct execution assumes ? parameter sql that requires literal binding) expect only literal parameters. We cannot generally push non-literals unless we add a capability and possibly extension metadata on procedures - alternatively all procedure handling on sources that do support non-literal arguments would need modified. At this point it seems sufficient to just allow this at a translator language level and mark the issue as partially completed. This can be revisited if critical for performance or if it's the only way to address a particular case.

            A little of the work for this was started by TEIID-2572

            Steven Hawkins added a comment - A little of the work for this was started by TEIID-2572

            partial patch

            Steven Hawkins added a comment - partial patch

            Looked at implementing this. It is more involved than it seems since the planner currently doesn't check pushdown for parameters and quite a few paths assume that parameters will be evaluated. The workaround is to use a scalar subquery that selects the desired value, which is less than ideal since it needs to reference a source table and issues a separate source query for each argument. This can also be implemented in a non-breaking fashion (at least from an api perspective - there would still be cases where custom translators would expect literals, but get Expressions) by just adding a get/setValue to Argument that use Expressions. Because of the workaround and that this is not necessarily a breaking change pulling out of 8.0

            Steven Hawkins added a comment - Looked at implementing this. It is more involved than it seems since the planner currently doesn't check pushdown for parameters and quite a few paths assume that parameters will be evaluated. The workaround is to use a scalar subquery that selects the desired value, which is less than ideal since it needs to reference a source table and issues a separate source query for each argument. This can also be implemented in a non-breaking fashion (at least from an api perspective - there would still be cases where custom translators would expect literals, but get Expressions) by just adding a get/setValue to Argument that use Expressions. Because of the workaround and that this is not necessarily a breaking change pulling out of 8.0

            In instances where a pushdown only expression is needed as a procedure parameter, this can be seen as a defect. In some circumstances that can be worked around using nested or common table expressions.

            Steven Hawkins added a comment - In instances where a pushdown only expression is needed as a procedure parameter, this can be seen as a defect. In some circumstances that can be worked around using nested or common table expressions.

              rhn-engineering-shawkins Steven Hawkins
              rhn-engineering-shawkins Steven Hawkins
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: