A predicate pushdown correctness guarantee method and system for multi-source heterogeneous queries under a data weaving platform

By acquiring and translating predicate conditions from multi-source heterogeneous queries through a data weaving platform, ensuring that they are executed on the target data source or locally, the problem of incomplete predicate pushdown in existing technologies is solved, thus achieving the correctness and completeness of query results.

CN123178449APending Publication Date: 2026-11-27广州睿帆科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611680864.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-28
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In existing technologies, when performing multi-source heterogeneous queries on a data weaving platform, there is a problem that conditions are not pushed down and there is no local execution location during the predicate pushdown process, causing the result set to deviate from the semantics of the original query execution plan.

Method used

By obtaining the query execution plan of the union query statement, the predicate conditions to be pushed down are determined, and the same translation entry is called one by one to determine whether the conditions can be translated into query fragments in the target external data source. If all conditions are successfully translated, an alternative scan operator is generated to replace the original scan operator; otherwise, no replacement is made to ensure that the conditions are executed in the target data source or locally.

Benefits of technology

It ensures the correctness of predicate pushdown, guarantees the semantic consistency and accuracy of query results, avoids the state where conditions are not pushed down or have no local execution location, and improves the integrity of query execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178449A_ABST
    Figure CN123178449A_ABST
Patent Text Reader

Abstract

The present application relates to the field of data processing, and provide a kind of predicate pushdown correctness guarantee method and system for multi-source heterogeneous query under data weaving platform, including obtaining the query execution plan of joint query statement, determine the predicate condition to be pushed to target external data source execution and the query statement generated by this time rewriting will be cancelled together with the condition of being examined, the condition of being examined includes filter predicate, limit condition and connection condition, and the condition of being examined is generated accordingly;Call the same translation entry as the query statement is generated one by one, read the relationship alias and field type referred to by the condition, obtain query fragment or different value null mark;Determine whether all conditions are obtained query fragment, if yes, generate the query statement and replace original scanning operator, cancel local carrying position, if not, do not generate and replace.This application makes the same range of being examined and cancellation range, rewriting occurs or does not occur on the whole execution plan.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing, and in particular to a method and system for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform. Background Technology

[0002] The data weaving platform virtualizes data scattered across various heterogeneous systems such as relational databases, data lakes, search engines, and object storage into data assets that can be queried uniformly through unified data source registration and logical dataset modeling. Then, leveraging the external data directory connectors of a distributed query engine, it initiates multi-source heterogeneous joint queries across multiple external data directories on these assets. In this product form, users access logical datasets, and the platform rewrites queries targeting these datasets into joint query statements, which are then executed by the distributed query engine. The query engine then attempts to push down filtering conditions, joins, and aggregation operations to external data sources for execution.

[0003] In existing technologies, when a distributed query engine executes a query, one approach is to rewrite the join and its filtering conditions as a whole into a remote query statement, replace the original scan operator in the pushed-down plan subtree with the remote query statement, and make the replacement scan operator no longer carry the original local scan predicate; another approach is to determine on the connector side whether the filtering predicate can be translated into the remote dialect according to the target data source capabilities, write the pushable part into the remote query, and retain the non-pushable part in the form of the push-down remainder for local execution; yet another approach is to determine whether a certain type of operation can be pushed down using a pre-enumerated list of data source capabilities.

[0004] However, in the above approach, if the entire query is rewritten into a remote query, the filtering conditions in the rewritten execution plan can only be carried by either the local scan predicate or the remote query. Once the replacement scan operator no longer carries the original local scan predicate, this local carrying position no longer exists. At this point, if a condition is skipped because it cannot be translated, then that condition is neither pushed down nor has a local execution position, and the result set deviates from the semantics of the original query execution plan. If the approach is to determine each capability individually or to enumerate by list, the premise of keeping the non-pushdownable parts for local execution does not hold under the overall rewrite, and the scope of capabilities on which the determination is based does not extend to the generation path actually used by the remote query. Even if the determination passes, the conditions may still be lost during generation.

[0005] Therefore, a third state is needed where the conditions consumed by the current rewrite do not fall into either a state that is neither pushed down nor has a local execution location. Summary of the Invention

[0006] This application proposes a method and system for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform, which solves the technical problem of incomplete condition acceptance in the prior art when implementing condition acceptance in the pushdown path.

[0007] To achieve the above objectives, this application provides the following technical solution: Firstly, this application proposes a method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform. This method is applied to the optimization stage of a distributed query engine and executed by the distributed query engine, including: Obtain the query execution plan of the union query statement, determine the predicate conditions to be pushed down to the target external data source for execution, and the checked conditions that will be revoked along with the query statement generated in this rewrite. The checked conditions include filtering predicates, row restriction conditions and join conditions. Based on the tested conditions, a set of tested conditions is generated; Read each condition in the set of conditions to be inspected one by one, and call the same translation entry point used to generate the query statement for each condition; Read the relation alias referenced by the condition and the type of the input field referenced by the condition in the target external data source, determine the translation result of the condition, and the translation result is a query fragment or, if it fails to be translated, a null value that is different from the value of the query fragment and stored. Determine whether all conditions in the tested condition set yield the query fragment; If so, the query statement is generated to replace the original scan operator in the query execution plan, the query statement is bound to the replacement scan operator, and the local bearer position of the checked condition on the original scan operator is revoked, where the local bearer position is the local scan predicate attached to the original scan operator. If not, then do not generate or replace the query execution plan, and output the query execution plan.

[0008] In conjunction with the first aspect, in one possible implementation, the invocation of the same translation entry point as that used to generate the query statement includes: Read the left and right inputs of the plan subtree where the original scan operator is located in the query execution plan, bind the left input as a left relation alias, and bind the right input as a right relation alias; For the filtering predicate input on the left, call the left-hand relation alias to perform translation and record the translation result; For the filter predicate input on the right, call the right-side relation alias to perform translation and record the translation result; For the join condition of the join operator and the predicate attached to the join operator itself, translation is performed using the relation alias group formed by the left-hand relation alias and the right-hand relation alias, and the translation result is recorded; wherein, The translation entry point called by the translation is the same entry point called by the translation entry point used to generate the query statement, rather than a general expression generation entry point without relational aliases; The tested conditions are carried in the form of a scalar expression tree; wherein... The nodes of the scalar expression tree carry the operator type and engine type, and the child nodes of the scalar expression tree express column references, constants, comparisons, logical AND, logical OR, negation, IN, LIKE, null value judgment, CAST, CASE WHEN and function calls; Read the names that can be referenced within the current input scope, and determine the column names that can be referenced under the relation alias based on the names that can be referenced.

[0009] In conjunction with the first aspect, in one possible implementation, the step of reading each condition in the set of examined conditions and calling the same translation entry point used to generate the query statement for each condition includes: For each condition in the set of tested conditions, perform a logical AND decomposition to obtain the conjunctive set of the conditions; For each conjunct in the set of conjuncts, first read the target dialect used by the target external data source and the type context of the columns referenced by the conjunct, then call the translation entry to convert the conjunct into a query fragment, and execute the recording according to the conversion result: If the conjunction is successfully transformed, the query fragment obtained by the transformation of the conjunction is recorded; if the conjunction exists but cannot be transformed, a null value is written to the conjunction. If the condition, after the split, does not contain any conjunction terms, then the condition record set is empty; where, The null value marker and the empty set are recorded as different values ​​from each other, so that when judging and reading the null value marker and the empty set, the condition can be distinguished as either a case where no conjunctive terms are generated or a case where conjunctive terms exist but cannot be translated.

[0010] In conjunction with the first aspect, in one possible implementation, for each conjunct item obtained by splitting each condition in the set of tested conditions, the type context of the column referenced by the conjunct item includes a first purpose and a second purpose; wherein, The first purpose is performed by the following actions: Read the original type name from the driver report and retain the original type name alongside the normalized generic type from the data weaving platform. For primitive type names with type wrappers, first remove the type wrappers, then perform normalization on the primitive type names after removing the wrappers in sequence, including removing quotes, converting to lowercase, removing type parameter parentheses, and removing pattern prefixes, and record the normalized primitive type names. Read the target dialect used by the target external data source and the specific form of the conjunction. Perform a joint comparison between the normalized original type name and the target dialect and the specific form of the conjunction. If the normalized original type name matches a special string type under the target dialect and the conjunction is a comparison between a column and a string, or a LIKE or IN form, then the translation result of the conjunction is determined to be a failure, and a null value flag is written to the conjunction. Otherwise, the translation result of the conjunctive terms is retained; The second purpose is performed by the following actions: Read the engine type of the column referenced by the other operand in the comparison condition that is opposite to the constant operand, and use the read engine type as the target type; The constant operands are written according to the target type and the target dialect; wherein... For date and time types, in the standard dialect, write a string literal with quotes and escaped inner quotes; in the Oracle dialect, write it in the form of TO_DATE or TO_TIMESTAMP respectively. If the constant operand itself is a string type, then the basic translation result of the constant operand is retained; The first purpose and the second purpose read different types of sources.

[0011] In conjunction with the first aspect, in one possible implementation, replacing the original scan operator in the query execution plan with an alternative scan operator further includes: When establishing the output of the query statement for the plan subtree where the original scan operator is located, an ordered output contract is generated; wherein, the output contract is written into the output items arranged in order and the retrieval mapping between each output item and the column reference operator in the plan subtree, and each output item is written with column reference, column object, remote alias and sequence number; When constructing the output contract, verify that the output items are not empty, the sequence numbers are consecutive, the column references are not repeated, and the remote aliases are not repeated after ignoring case, and record the verification results. According to the order of the output contracts, write the remote aliases sequentially to the SELECT output columns of the query statement; When setting the query statement for the alternative scan operator, verify whether the output contract matches the scan column metadata and record the matching result; During the execution plan construction phase, the scan column slots on the target external data source side are established in the order of the same output contract, so that the remote output column order corresponds to the local receiving column order. If the column referenced by the filtering predicate is not in the final output column, the filtering is first completed at the source relation level, and then the projection is performed on the required output column to establish a new output contract. For objects to be combined that only have the query statement text written but no output contract to be combined, output the query execution plan.

[0012] In conjunction with the first aspect, in one possible implementation, the determination of the examined conditions and the generation of the query statement when all conditions yield query fragments also respectively perform the following semantic position constraint actions: For the filtering predicate and the row restriction condition of the outer table scan operator, the original level of the input corresponding to the outer table scan operator is read, and the filtering predicate and the row restriction condition are executed according to the original level, so that the filtering predicate is executed before the original row restriction condition of the input, while the new filtering predicate for the already restricted remote relation is written after the row restriction condition for execution; wherein, the order of the row restriction condition and the filtering predicate in the original level remains unchanged; For outer joins, read the original filtering predicate input on the side with the padded null value, so that the original filtering predicate is executed before the padded null value is filled and is not migrated to the filtering level above the rewritten join; Read the conditions across both sides, determine and bind the equivalence conditions across both sides as equi-join keys, do not generate or replace the unsupported cross-side residual conditions, and output the query execution plan. If the required equi-join key is missing, do not generate or replace it, and output the query execution plan. In the aggregate join pushdown path with an inner join type, the query statement is generated only for the plan subtree where the original scan operator with an inner join type is located. If the join type is not an inner join, it is not generated or replaced, and the query execution plan is output.

[0013] In conjunction with the first aspect, in one possible implementation, the method further includes: The output contract and the query statement are recorded together as the execution conditions required for execution on the target external data source side; When the original scan operator contains an outer join that needs to be executed with null-padding semantics at the remote end, and other remote relation combinations are superimposed on it, the execution settings for instructing the target external data source to execute the outer join with null-padding semantics are obtained. The execution settings are merged from the lower-level input upwards, passed to the scan operator on the target external data source side through the alternative scan operator, and the execution settings are appended to the query statement in the form of a setting statement. This ensures that the execution requirements of the nested outer join for null-padding semantics are preserved, rather than just the query statement text.

[0014] In conjunction with the first aspect, in one possible implementation, before determining whether all conditions in the set of examined conditions have yielded a query fragment, the method further includes: Perform capability probing on the target external data source; wherein, the capability probing includes: The ability to detect the external data source of the target is initially set to a disabled state; Read the version of the target external data source, compare whether the version meets the preset version conditions, and record the version comparison result; Perform actual detection on the capability to be detected and record the detection results; wherein, the actual detection includes an execution check and a result contract check, the execution check verifies whether the detection statement is executable, and the result contract check, based on the executableness of the detection statement, further verifies whether the value form or result set of its returned result corresponds to the value method and expected semantics used when reading the result of the target external data source locally; If the version comparison result indicates that the version meets the preset version condition and the detection result indicates that the actual detection meets the preset detection requirements, then the capability to be detected is written as an allowed state and the corresponding conditions are pushed down accordingly. If the version comparison result indicates that the version does not meet the preset version conditions, or if the detection result indicates that the actual detection does not meet the preset detection requirements, then the prohibited state of the capability to be detected is retained; wherein, The capability detection is performed once during metadata initialization, and is not re-executed when the metadata table is refreshed.

[0015] In conjunction with the first aspect, in one possible implementation, the method further includes: Read the aggregation parameter expression received by the aggregation operator in the plan subtree where the original scan operator is located; If the column referenced by the aggregation parameter expression is a temporary column generated by the projection in the plan subtree where the original scan operator is located, rather than a physical column of the source table, then the following actions are performed to restore the temporary column to a physical column of the source table, and the restored expression is placed into the set of checked conditions as a checked condition: Collect and record the projection mapping of the planned subtree where the original scan operator is located; The temporary column referenced by the aggregation parameter expression is recursively expanded along the projection mapping, and the temporary column is successively converted into the actual transformation expression, function expression or other expression to generate the restoration expression; During the recursive expansion process, the columns being expanded are recorded; When expanding to the same column that has already been recorded but has not yet been fully expanded, the same column is not expanded again and a stop-expansion flag is written. The translation entry is called to perform translation on the restored expression, and its query fragments or null value markers are recorded so that the projection temporary column name is not used as the source table column name in the assembly. References that still cannot be mapped to a column in the source table after the expansion is stopped are recorded as null values.

[0016] Secondly, this application also proposes a predicate pushdown correctness guarantee system for multi-source heterogeneous queries under a data weaving platform, applied to the optimization stage of a distributed query engine, including: The inspection analysis module is used to obtain the query execution plan of the joint query statement, determine the predicate conditions to be pushed down to the target external data source for execution, and the inspection conditions that will be revoked along with the query statement generated in this rewrite. The inspection conditions include filtering predicates, row restriction conditions and join conditions. Set construction module: used to generate a set of test conditions based on the test conditions; Translation module: Used to read the conditions in the set of conditions to be inspected one by one, and call the same translation entry point as the one used to generate the query statement for each condition; Verification module: used to read the relation alias referenced by the condition and the type of the input field referenced by the condition in the target external data source, determine the translation result of the condition, the translation result being a query fragment, or, if translation fails, a null value that is different from the value of the query fragment and stored. The judgment and replacement module is used to determine whether all conditions in the tested condition set have yielded the query fragment; If so, the query statement is generated to replace the original scan operator in the query execution plan, the query statement is bound to the replacement scan operator, and the local bearer position of the checked condition on the original scan operator is revoked, where the local bearer position is the local scan predicate attached to the original scan operator. If not, then do not generate or replace the query execution plan, and output the query execution plan.

[0017] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.

[0018] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0019] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.

[0020] In the attached diagram: Figure 1 This is a flowchart of a method for ensuring the correctness of predicate pushdown in a multi-source heterogeneous query under a data weaving platform, as described in an embodiment of the present invention. Figure 2 This is a system composition diagram of a predicate pushdown correctness assurance system for multi-source heterogeneous queries under a data weaving platform, as described in an embodiment of the present invention. Figure 3 This is a diagram illustrating the overall architecture of the distributed query engine in this embodiment of the invention. Figure 4 This is a schematic diagram of relational alias mapping under the same translation entry point in an embodiment of the present invention; Figure 5 This is a schematic diagram illustrating the consistency between the inspected area and the revocation area, and the pairwise occurrence of the exit action in an embodiment of the present invention; Detailed Implementation

[0021] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0022] like Figure 3As shown, this application primarily focuses on the query optimization phase of the distributed query engine, which is a customized branch based on an open-source distributed query engine. When executing the methods of this application, the distributed query engine utilizes JDBC metadata caching and connection pooling to reduce the cost of repetitive metadata access and connection establishment. For example, caches are set for partition names, table instances, partition information, and table identifiers. The first three types of caches are controlled by enable configuration and write expiration time. The connection pool has default values ​​for maximum pool size, minimum number of idle connections, and idle timeout. The keys for the metadata cache can include directory name, database name, and table name. It is important to clarify that the cache and connection pool operate on metadata and connections, not on caching the conditions for translation results. Translation rules typically create constructors, lists, and mappings within the call; this invention does not claim any caching or reuse of translation results.

[0023] In this application, the query statement is assembled by the distributed query engine according to the dialect used by the target external data source, and is used to bear the query conditions on the target external data source side; the tested conditions refer to the filtering predicates, row restriction conditions, and join conditions that will be revoked along with the query statement to be pushed down; the local carrying position refers to the position where the filtering semantics are carried by the original scanning predicates of the original scanning operator before rewriting, which is also the local scanning predicates attached to the original scanning operator. The remote query statement referred to in the background section is the query statement to be pushed down in this specification. Example 1

[0024] like Figure 1 As shown, this application proposes a method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform. This method is applied to the optimization stage of a distributed query engine and is executed by the distributed query engine. Its features include: First, the scope of inspection is determined, which includes: obtaining the query execution plan of the union query statement, determining the predicate conditions to be pushed down to the target external data source for execution, and the inspection conditions that will be revoked along with the query statement generated in this rewrite. The inspection conditions include filtering predicates, row restriction conditions, and join conditions. The union query statement spans multiple external data directories, and each external data directory corresponds to a heterogeneous external data source.

[0025] Generate a set of test conditions based on the test conditions; When pushing down the query statement, the semantic model of the query execution plan expresses the relationship between operators, column references, and expressions, based on the boundaries of the checked conditions, not on the enumeration of condition types or the source of conditions. It does not include the dimension of condition source. The same comparison expression on the same column, whether written by the user, injected by the platform during the rewrite phase, or derived by the optimizer, will appear as the same predicate in the plan, and these three are indistinguishable within the plan. If the checked scope is defined by the source, it must be based on the premise that the source information is available within the plan. Without introducing an additional source-carrying mechanism, this premise does not hold. The requirement for the identity of the checked scope and the undoing scope is that when the query statement replaces the original scan operator with a replacement scan operator, the replacement scan operator no longer carries the original scan predicate, and the local carrying positions of the filtering predicate and the row restriction conditions disappear. Join conditions are merged into the query statement to be pushed down along with the join operator. The above three types of conditions are all conditions that will be undoed during the rewrite; whether they are taken over by the query statement to be pushed down is irrelevant to who generated them. Using the scope of revocation as the boundary, the scope of inspection and the scope of revocation are identical in the plan structure, without relying on the enumeration of the completeness of the condition types.

[0026] The above steps determine the set of objects for subsequent translation and judgment, ensuring that the set of inspected conditions has the same extension as the set of conditions to be revoked during this rewrite. The three types of conditions revoked during this rewrite—filter predicates, line-limiting conditions, and join conditions—all enter the same set of inspected conditions, eliminating any omissions that fall within the revocation scope but are not inspected. Tenant isolation conditions and row-level permission filtering conditions injected from the platform, provided they are already visible in the query optimization stage, are subject to the same constraints as user-written query conditions and are not treated differently based on their source on the rewrite path.

[0027] Read each condition in the set of conditions to be inspected, and call the same translation entry as the generated query statement for each condition; Read the relation alias referenced by the condition, and the type of the input field referenced by the condition in the target external data source, determine the translation result of the condition, and mark and store the translation result as a query fragment or, if it fails to be translated, a null value that is different from the value of the query fragment. In one embodiment of this application, the translation entry point is limited to the same translation entry point used to generate the query statement to be pushed down, addressing the gap between the capabilities upon which the judgment is based and the capabilities of the generation. In the planned rewrite, there are multiple entry points for generating the query fragment from the expression, including: a general expression generation entry point without relational aliases, and a translation entry point with relational aliases that simultaneously completes the positioning of column references on the input. The supported scope of the two may differ; an expression that the general expression generation entry point can generate may not be generated by the translation entry point because the translation entry point also needs to complete the column attribution resolution under the relational alias, and some expression forms are not yet supported by the translation entry point. If the judgment calls the general expression generation entry point, passing the judgment does not necessarily mean that the actual generation will succeed. Therefore, using the translation entry point as the sole source of answer ensures that there is only one judgment subject for whether translation is possible in this rewrite. Outputting a null value flag that differs from the query fragment value when translation fails addresses the criterion form of the judgment step: if an empty string or empty set indicates translation failure, the judgment step cannot distinguish between the absence of a condition and the presence of a condition but inability to translate, rendering the judgment meaningless.

[0028] Before the rewriting action occurs, the acceptability of each condition is confirmed one by one at the actual translation entry points, and a conclusion that can be directly read by subsequent judgments is left for each condition. This can eliminate the gap between the ability to generate a value and the ability to actually generate a value, so that the completeness of the acceptance has a verifiable basis before the rewriting action is executed; the conditions of translation failure are not silently skipped, but are explicitly propagated to the judgment step with a null value marker.

[0029] Determine whether all conditions in the tested condition set yield a query fragment; In one embodiment of this application, the determination is based on whether all conditions have obtained query fragments, rather than whether some conditions have obtained query fragments. This is because the scope of the rewrite is holistic; once the query statement to be pushed down replaces the original scanning operator, the local carrying positions of all conditions in the tested condition set are cancelled, regardless of whether a particular condition is accepted. Therefore, if any condition fails to obtain a query fragment, the query statement to be pushed down cannot fully accept the filtering semantics of the tested condition set on the external data source side, making partial acceptance meaningless.

[0030] If so, a query statement is generated to replace the original scan operator in the query execution plan, the query statement is bound to the replacement scan operator, and the local bearer position of the checked condition on the original scan operator is cancelled. The local bearer position is the local scan predicate attached to the original scan operator. If not, then no query execution plan will be generated or replaced.

[0031] In one embodiment of this application, the exit is designed to occur in pairs due to the irreversibility of the replacement action. Replacing the original scan operator with a replacement scan operator and removing the original scan predicate from the replacement scan operator means that the local location carrying the filtering semantics of the original scan predicate no longer exists; any gaps in the connection discovered after the assembly action cannot be remedied by subsequent processing. Therefore, not generating and not replacing must occur as a single, integrated action: if only a portion of the action is abandoned after a gap is discovered—for example, still generating the query statement to be pushed down but not performing the replacement, or performing a partial replacement—the execution plan will be in an intermediate state that is neither the original plan nor a complete rewrite result. Conversely, by ensuring that neither generation nor replacement occurs, this rewrite has no effect on the execution plan, and the original query execution plan and its carrying filtering semantics are completely preserved. Confirming the integrity of the connection is completed before the irreversible action of removing the original scan predicate from the replacement scan operator; incomplete connection renders the entire rewrite invalid.

[0032] This rewrite affects the execution plan by either causing the entire plan to occur or preventing it from occurring entirely. The conditions in the checked condition set will not exhibit a third state in the rewritten execution plan: neither being pushed down nor having a local execution location. That is, the conditions will either be handled by the query statement to be pushed down on the external data source side, or remain entirely in their original state and be handled locally. Since the exit is atomic, failure will not leave behind an intermediate state that is neither the original plan nor a complete rewrite result. Example 2

[0033] like Figure 4 As shown, this application includes the following steps in the process of calling the same translation entry point as the query statement generation process: Read the left and right inputs of the plan subtree where the original scan operator is located in the query execution plan, bind the left input as a left relation alias, and bind the right input as a right relation alias; For the filtering predicate input on the left, call the left-hand relation alias to perform translation and record the translation result; For the filtering predicate input on the right, call the right-hand relation alias to perform translation and record the translation result; For the join condition of the join operator and the predicate attached to the join operator itself, translation is performed using the relation alias group consisting of the left-hand relation alias and the right-hand relation alias, and the translation result is recorded; where, The translation entry point called by the translator is the same entry point called by the translator to generate the query statement, rather than the general expression generation entry point without relational aliases; The tested conditions are carried in the form of a scalar expression tree; among them, The nodes of the scalar expression tree carry the operator type and engine type. The child nodes of the scalar expression tree express column references, constants, comparisons, logical AND, logical OR, NOT, IN, LIKE, null value checks, CAST, CASE WHEN, and function calls. Read the names that can be referenced within the current input scope, and determine the column names that can be referenced under the relation alias based on the names that can be referenced.

[0034] In one specific embodiment of this application, aliases are mapped and translated separately for each side. This is because the inputs on both sides of the connection each have independent namespaces in the query statement to be pushed down. Columns with the same name may exist on both sides. If relation aliases are not assigned to the inputs on both sides, the column reference on one side cannot be determined in the generated query fragment. Therefore, the filtering predicates of the inputs on both sides must be translated under their respective relation aliases, and cannot be translated outside their namespaces. The join condition and the predicates attached to the join operator itself involve both sides, so they are translated according to the same relation alias group. There is a crucial boundary here: the column names that can be referenced under the relation alias are based on the names that can be referenced within the current input scope, not necessarily the external physical column names. Column names may use different name sources under different paths, and the names that can be used depend on the set of names that the current scope of the path can resolve. If both are treated as identical, it is possible that the translated column name will not exist at the remote end or will point to the wrong column.

[0035] This application uses a scalar expression tree as the carrier form, enabling the operator structure of conditions to be expressed in the plan as nodes and relationships between nodes, thereby supporting recursive translation of arbitrary subtrees. Nodes carry operator types and engine types, so that the translation process does not need to look up type information when traversing nodes. The column references, constants, comparisons, logical AND, logical OR, NOT, IN, LIKE, null value judgments, CAST, CASE WHEN, and function calls expressed by child nodes constitute the set of forms that the translation process needs to cover. One boundary that needs to be clarified is that the scalar expression tree is an intermediate representation for condition translation, and its connotation is the expression tree itself that carries the operator structure, not a separately defined set of source-specific intermediate representations; the several state markers already on the scalar expression tree, such as markers indicating whether it can be used for pushdown, whether it is related, and whether it is derived from a connection, are not condition source markers and cannot be used to identify the source of the condition.

[0036] This ensures that the translation process, from the initial judgment stage to the generation stage, uses the same expression tree, the same relational alias path, and the same name resolution criteria. Therefore, the judgment conclusions and generation results of this application remain consistent across the three dimensions of object, path, and name resolution, preventing discrepancies in form or namespace between the objects processed in the judgment and those processed in the generation stage. The attribution of identically named columns on both sides is determined during the translation stage and is not carried over to the generation stage. Example 3

[0037] like Figure 5 As shown, this application reads each condition in the set of conditions to be inspected and calls the same translation entry point as the one used to generate the query statement for each condition, including: For each condition in the set of conditions to be checked, perform a logical AND decomposition to obtain the conjunctive set of the conditions; For each conjunct in the conjunct set, first read the target dialect used by the target external data source and the type context of the columns referenced by the conjunct, then call the translation entry to convert the conjunct into a query fragment, and execute the records according to the conversion results: If the conjunction is successfully transformed, the query fragment obtained after the transformation is recorded; if the conjunction exists but cannot be transformed, a null value is written to the conjunction. If the condition, after being split, contains no conjunctions, then the set of condition records is empty; where, Record the null value marker and the empty set as different values ​​to distinguish whether the condition for reading the null value marker and the empty set belongs to the case where no conjunctive terms are generated or the case where conjunctive terms exist but cannot be translated.

[0038] In one embodiment of this application, the application uses a combination of logical AND decomposition and three-value records. Logical AND decomposition expands a set of complex conditions into several independently determinate units. Logical AND has the property that if any conjunction is false, the whole condition is false. Therefore, the item-by-item determination of whether a conjunction can be translated can be directly combined into a determination of whether the entire set of conditions can be fully accepted. Without decomposition, only the entire set of conditions can be determined, making it impossible to pinpoint which conjunction is unacceptable, thus preventing the formation of a clear interception conclusion before the rewriting action. The role of three-value records is to distinguish between two different outputs: one where no acceptable conjunction is generated, and another where a conjunction exists but cannot be translated. The former corresponds to an empty set of objects to be translated, which can be legally represented as an empty set; in this case, the query statement to be pushed down does not need to provide acceptance for any conditions. The latter corresponds to objects existing but unable to generate corresponding fragments, and must be represented by values ​​that cannot be confused with the former. If both use the same representation, such as both representing an empty set or both representing an empty string, the judgment step cannot determine whether there is an unaccepted condition, and the exit criterion will always be that there is no failed item, so the integrity of the acceptance cannot be determined.

[0039] When determining whether a query fragment has been obtained, a composable and locatable decision result is provided, and failed conjuncts are propagated to the decision step with null values. Failed conjuncts are not silently skipped; the completeness of the conditional conjunction has a definite value at the decision level, making overall exit an executable criterion; failed items in composite conditions can be located at the conjunct level, rather than simply receiving a non-locatable conclusion of the entire set of failures. Example 4

[0040] For each conjunct obtained by decomposing each condition in the tested condition set, the type context of the column referenced by the conjunct includes a first purpose and a second purpose; wherein... The primary purpose is performed by the following actions: Read the original type name from the driver report and retain it alongside the common type normalized by the data weaving platform. For primitive type names with type wrappers, first remove the type wrappers, then perform normalization on the primitive type names after removing the wrappers in sequence, including removing quotes, converting to lowercase, removing type parameter parentheses, and removing pattern prefixes, and record the normalized primitive type names. Read the target dialect and the specific form of the conjunction used by the target external data source. Perform a joint comparison between the normalized original type name and the target dialect and the specific form of the conjunction. If the normalized original type name matches a special string type under the target dialect and the conjunction is a comparison between a column and a string, or a LIKE or IN form, then the translation result of the conjunction is judged as a failure and a null value is written to the conjunction. Otherwise, retain the translation result of the conjunction; In one embodiment of this application, The primary purpose is to retain the original type names in the driver report and coexist with the generic type. This is because their information sources and uses are opposite: the generic type aims to model multiple heterogeneous data sources in a unified way, requiring the normalization of external proprietary types during the metadata collection phase to smooth out differences and facilitate unified processing; the original type names are taken from the source-side type names reported by the driver when reading metadata, preserving source-side type information. Therefore, it can be used to determine whether a column has comparative semantics different from the platform's normalization result on the remote end. For example, source-side document types, Extensible Markup Language types, some geometric types, and network address types may be normalized to string types on the platform side. These columns are represented as strings on the platform side, but their operator semantics on the source side are not equivalent to ordinary strings. The first purpose sets the judgment condition to match specific string types and conditions involving comparisons between columns and strings, or combined LIKE or IN operations, rather than prohibiting related operations by type name. This is because type risk is conditional: semantic inequivalence only occurs when a column is actually compared using string semantics. Other operations on the same column, such as equi-joins with other types of columns, are unaffected. Prohibiting all operations by type name would unnecessarily forgo available pushdown opportunities. The first purpose requires four normalization steps before matching: dequoting, unifying lowercase, removing type parameter parentheses, and removing pattern prefixes. This is because the same type may appear in metadata from different data sources with quotes, length or precision specifications, pattern qualifiers, and different capitalization; without normalization, it will fail to match. The first purpose also requires unwrapping the type before normalization because the outer wrapper does not change the semantics of the inner type. Matching with the wrapped name would cause types that should have been matched to be missed.

[0041] The secondary purpose is performed by the following actions: Read the engine type of the column referenced by the other operand in the comparison condition that is opposite to the constant operand, and use the read engine type as the target type; Write constant operands according to the target type and target dialect; where... For date and time types, in the standard dialect, write a string literal with quotes and escape the inner quotes; in the Oracle dialect, write it in the form of TO_DATE (date constant) or TO_TIMESTAMP (time constant). If the constant operand itself is a string type, the underlying translation result of the constant operand is preserved; In one embodiment of this application, the second purpose takes the engine type of the comparison peer column as the target type, rather than the type of the constant operand itself. This is because the same constant needs to be presented in different valid forms when compared on columns of different types, and the type of the other column being compared determines its valid form. For example, with date and time constants: if they are directly assembled into literals without quotes according to their local type, the literal may be parsed as numerical operations or expressions on the remote end, thus making it impossible to compare with the target column using date and time semantics. In Oracle dialects, date and time constants also need to be written in the form of explicit conversion functions to match the value form of the target column. The reason why the second purpose maintains its basic translation result when the constant operand itself is a string type is that the writing form of string constants does not change with the peer column type, and in this case, there is no need to apply type-driven rewriting.

[0042] The first and second uses read different types of sources.

[0043] In one embodiment of this application, the first purpose is to read the original type name from the driver report, normalize it, and jointly determine it with the target dialect and conditional form; the second purpose is to read the engine type of the comparison counterpart column; the two purposes are not merged into a single priority relationship where the original type name is always given priority, nor do they constitute a single priority relationship where the original type name always takes precedence over the general type. These two purposes serve two different problems: the former is whether such comparisons on a certain column may be semantically inequivalent, and the latter is what legal literal form the constant should be written in; their judgment objects, information sources, and conclusion forms are all different, therefore they cannot be uniformly expressed by a single priority rule. If forcibly merged, the original type name would be incorrectly used in situations where the engine type needs to be used as the target type, and the engine type would be incorrectly used in situations where the original type name needs to be used to determine risk.

[0044] This application enables type safety determination and the legal writing of constants to regain the source and peer type information that was erased by normalization. This reduces remote execution errors and result deviations caused by semantic inequivalence in comparison of proprietary types and illegal forms of constant literals; the two uses are independent and effective based on their own information sources, and do not overwrite each other. Example 5

[0045] This application replaces the original scan operator in the query execution plan with an alternative scan operator, and also includes: When creating the output of the query statement for the plan subtree where the original scan operator is located, an ordered output contract is generated; wherein, the output contract is written into the output items arranged in order and the retrieval mapping between each output item and the column reference operator in the plan subtree, and each output item is written with column reference, column object, remote alias and ordinal number; When constructing the output contract, verify that the output items are not empty, the serial numbers are consecutive, the column references are not repeated, and the remote aliases are not repeated after ignoring case, and record the verification results. Write the remote aliases sequentially to the SELECT output columns of the query statement according to the order of the output contracts; When setting up a query statement for an alternative scan operator, verify that the output contract matches the scanned column metadata and record the matching results; During the execution plan construction phase, the scan column slots on the target external data source side are established in the order of the same output contract, so that the remote output column order corresponds to the local receiving column order. If the column referenced by the filtering predicate is not in the final output column, the filtering is first completed at the source relation level, and then the projection is performed on the required output column and a new output contract is established. Output the query execution plan for objects to be combined that only contain the query text and do not contain output contracts that can be further combined.

[0046] In one embodiment of this application, an explicit contract is used instead of string replacement of the query text. This is because a verifiable correspondence must exist between the output columns of the query statement to be pushed down and the local receiver. The output item list defines the output order, and the retrieval map is used to find the corresponding output item based on column references. Their functions are: the order determines the column order of the remote SELECT, and the lookup determines which output item a local column reference should be taken from. The four checks set during construction each address a type of failure: non-empty output items ensure contract usability; consecutive sequence numbers ensure no gaps in the order definition; unique column references ensure that the same column reference will not correspond to two output items, thus avoiding ambiguity when retrieving columns locally; and unique remote aliases after ignoring case are avoided because some dialects are not case-sensitive, and aliases must be unique after ignoring case to avoid alias conflicts during remote parsing.

[0047] This set of features addresses the issue of column order correspondence, not just text name non-duplication: the column order of the remote SELECT, the metadata verified by the alternative scan operator, and the column slots established during the physical execution phase must all be defined according to the same order; otherwise, when retrieving values ​​locally according to a fixed slot order, misplaced columns will be retrieved. Therefore, verifying the contract to match the scanned column metadata when setting the query statement to be pushed down is a consistency confirmation at the setting point; establishing column slots according to the same contract order is a confirmation of order at the execution plan construction point. If the column referenced by the filtering predicate is not in the final output column, filtering must first be completed at the source relation level, and then projection must be performed on the required output column to establish a new output contract: if a column is pruned before filtering that references that column, then the filtering will have no referenced objects at the pruned level, so filtering must be completed at the level where the filtering column can still reference it, and then the column must be pruned. For objects to be combined that only contain the query statement text without any output contract that can be further combined, the query execution plan is not generated or replaced. This is because such input cannot provide a column order basis when further combined by the upper layer, and accepting such input would prevent the establishment of a column order correspondence for upper-layer combination. This ensures a clear correspondence between the remote output column order and the locally received column order, and properly handles the dependency relationship between filter columns and output columns. It avoids column misalignment and condition loss caused by uncorresponding output column orders or premature pruning of filter columns.

[0048] It should be clarified that the copying of type information along the column in this embodiment has a clear coverage boundary. When creating an alias column, the type, nullability, and original type name can be copied, allowing the parent layer to obtain the preserved type context along the path. However, the same copying is not performed at another location where a new column is created using projection, and the output of the calculated expression cannot unconditionally inherit the type of any input. Therefore, the output contract and type copying along the column described in this embodiment do not constitute a complete type lineage system covering all projections and expressions, and this invention does not claim complete transmission of type lineage. Example 6

[0049] like Figure 5 As shown, the determination of the test conditions and the generation of the query statement when all conditions are obtained also involve the following semantic position constraint actions: For the filtering predicates and row restriction conditions of the outer table scan operator, the original level corresponding to the input of the outer table scan operator is read, and the filtering predicates and row restriction conditions are executed according to the original level, so that the filtering predicates are executed before the original row restriction conditions are input, while the new filtering predicates added to the already restricted remote relations are written after the row restriction conditions are executed; wherein, the order of row restriction conditions and filtering predicates in the original level remains unchanged; In one embodiment of this application, the filtering predicate and the limiting condition are not interchangeable in relational algebra semantics. The result set obtained by limiting first and then filtering is generally different from the result set obtained by filtering first and then limiting. Therefore, the rewrite must consume these two types of operations according to the level at which the conditions reside in the original execution plan: filtering located inside the input is executed at its original level, i.e., before the input is originally limited; while filtering newly added to a distant relation that is already limited should be executed outside the result set of the already limited relation. If the order of the two is arbitrarily interchanged in the rewrite, the size and content of the result set will change.

[0050] For outer joins, read the original filtering predicate input from the side with the padded null value, so that the original filtering predicate is executed before the padded null value is executed and is not migrated to the filtering level above the rewritten join; Read the conditions across both sides, determine and bind the equi-conditions across both sides as equi-join keys, do not generate or replace the unsupported cross-side residual conditions, and output the query execution plan. If the required equi-join key is missing, do not generate or replace it, and output the query execution plan. In the pushdown path of an aggregate join with an inner join type, query statements are generated only for the plan subtree where the original scan operator with an inner join type is located. If the join type is not an inner join, no query statement is generated or replaced, and the query execution plan is output.

[0051] In one embodiment of this application, the difference between an outer join and an inner join is that the outer join pads null values ​​for unmatched rows. The original filtering predicate on the null-padding side, in its original semantics, filters the input itself before the null values ​​are padded. If this is moved to a filtering level above the rewritten join, the filtering will act on the result after the join, thereby removing unmatched rows that should have been retained and changing the result set of the outer join. Therefore, the filtering must be performed before the null values ​​are padded, for example, by wrapping the input in the form of a filtering subquery. Equivalence conditions across both sides are identified as join keys because maintaining join semantics requires that the equivalence conditions take effect at the join point rather than being treated as ordinary filtering after the join. Unsupported cross-side residual conditions are rejected for pushdown because such conditions cannot be expressed as unilateral filtering on relations from two different sources. Pushdown is also rejected when the required equivalence join key is missing because a query with the corresponding join semantics cannot be formed at the far end.

[0052] In another possible implementation, in a path that allows partial pushdown, which is different from the path where the query statement to be pushed down completely replaces the original scan operator, if a branch in the composite logic condition is untranslatable, then the untranslatable branch is retained, and the remaining branches are pushed down without deleting the untranslatable branch.

[0053] If an untranslatable branch in a complex logical condition is deleted, the constraints of the remaining conditions become stronger than the original conditions, which is equivalent to relaxing the filtering and making the result set larger. Therefore, when the branch is untranslatable, the only option is not to push down the complex logical condition, but not to delete the branch and then push down the remaining branches. Here, it is necessary to distinguish the applicable boundaries of the two paths: the path that allows partial pushdown is judged by whether the conditions that have not been pushed down still have an execution position, so the pushable part can be sent to the pushdown position while the non-pushable part is kept in local filtering; however, the path that replaces the scanning operator with the entire query statement to be pushed down, i.e., the path targeted by Example 1, requires that the canceled condition be taken over by the replacement operator, so partial pushdown is not applicable.

[0054] In an aggregate join pushdown path with an inner join type, the query statement to be pushed down is generated only for the plan subtree containing the original scan operator with an inner join type. If the join type is not an inner join, it is not generated or replaced, and the query execution plan is output. The aggregate join pushdown path needs to simultaneously express the semantics of join, grouping, and aggregation at the remote end, and its generation form is related to the join type. The implementation of the path in this embodiment only generates the corresponding form of query statement for inner joins. For non-inner join join types, the capability boundary of the path does not allow the generation of the corresponding form of query statement; therefore, it exits by outputting the query execution plan, i.e., the rewrite is not performed, and the original query execution plan is retained. It should be clarified here that the limitation on the join type capability boundary of the aggregate join pushdown path in this embodiment is not used to limit the range of join types supported by ordinary join pushdown paths.

[0055] The above embodiments ensure that the execution position and semantics of the conditions during the rewriting process remain consistent with the original execution plan, and clearly define the capability boundaries of the connection types for each path. Technical benefits: Avoids semantic deviations caused by swapping the order of filtering and line-limiting, migrating pre-filters on the null value side, deleting untranslatable branches, and non-inner joins entering aggregate join pushdown paths. Example 7

[0056] The method in this application also includes: The output contract and query statement are recorded together as the execution conditions required for execution on the target external data source side; When the original scan operator contains an outer join that needs to be executed with null-filled semantics at the remote end, and there are other remote relation combinations superimposed on it, the execution settings used to instruct the target external data source to execute the outer join with null-filled semantics are obtained. The execution settings are merged from the lower-level input upwards, passed to the scan operator on the target external data source side through the replacement scan operator, and the execution settings are appended to the query statement in the form of a setting statement. This ensures that the execution requirements of the nested outer join for null-filled semantics are preserved, rather than just the query statement text.

[0057] In one embodiment of this application, during nested combinations, when a remote relation combination contains an outer join that needs to be executed with null-padding semantics on the remote end, the execution requirement is part of the execution semantics of the outer join. If the remote end does not handle the outer join with null-padding when executing it, the result of the outer join will not be as expected. When other remote relation combinations are superimposed on the remote relation and the parent layer combines the complete input query statement, the execution requirement of the child layer will not be naturally retained: if the object obtained and further combined by the parent layer only contains the text of the query statement, the execution semantic requirements, such as the execution settings used to instruct the target external data source to execute the outer join with null-padding semantics, are lost during the combination process. Therefore, this embodiment carries the execution settings together with the query statement to be pushed down, and merges them upwards from the lower layer input, passes them to the scan operator on the target external data source side via the alternative scan operator, and finally appends them to the query statement to be pushed down in the form of a setting statement. The reason why execution settings are merged upwards during combination instead of being re-inferred in the parent layer is that the information held by the parent layer may not be sufficient to restore the execution mode required by the outer join of the child layer.

[0058] This embodiment ensures that the execution requirements for null value semantics in the nested outer join are propagated upwards along with the composition relationship and are preserved. The goal is to ensure that the execution method of the outer join on the remote end is consistent with expectations, without losing its execution requirements due to the remote relationship being composed by the upper layer; the composition of the remote relationship carries not only the query text but also its execution semantic requirements. It is important to clarify here that the execution settings are remote execution conditions, not condition source markers; and not all attributes related to remote execution use the same merging method; other attributes are set separately according to the specific composition operation. Example 8

[0059] Before determining whether all conditions in the set of inspected conditions have been obtained from the query fragment, this application also includes: Perform capability probing on the target external data source; the capability probing includes: Initially disable the probe capabilities of the target's external data source; Read the version of the target external data source, compare whether the version meets the preset version conditions, and record the version comparison result; Perform actual probing on the probe capability and record the probe results; the actual probing includes execution check and result contract check. The execution check verifies whether the probe statement is executable. The result contract check, based on the executableness of the probe statement, further verifies whether the value form or result set of its returned result corresponds to the value method and expected semantics used when reading the result from the target external data source locally. If the version comparison results show that the version meets the preset version conditions and the detection results show that the actual detection meets the preset detection requirements, then the capability to be detected will be written as an allowed state and the corresponding conditions will be pushed down accordingly. If the version comparison results indicate that the version does not meet the preset version conditions, or if the detection results indicate that the actual detection does not meet the preset detection requirements, then the prohibited state of the capability to be detected will be retained; where, Capability detection is performed once during metadata initialization, and is not re-executed when the metadata table is refreshed.

[0060] In one embodiment of this application, the pushdown eligibility is determined jointly by version conditions and actual detection, rather than solely by a pre-enumerated list of capabilities. This is because syntactic executableness does not equate to the result being correctly readable locally; the behavior of the same capability may differ across versions, and the pre-enumerated list is limited by completeness and timeliness, potentially overlooking actual configuration differences in the target external data source and failing to automatically correct for changes in remote versions or configurations. Therefore, capabilities are initially set to a prohibited state, allowing them only when both version conditions and actual detection requirements are met; the prohibited state is maintained when the detection fails, i.e., it remains unavailable, thus preventing the corresponding pushdown from being enabled due to a failed detection. It is important to clarify that the detection targets the specific capability being probed, not a general proof of the entire semantics of the query statement, and is not executed for every query.

[0061] This embodiment confirms that the probe statement can be executed remotely through an executability check; the result contract check further confirms that the returned result corresponds in value form or result set to the method and expected semantics used when reading the target external data source result locally. The reason for adding a result contract check on top of executability is that if the remote execution is successful but the return value form does not match the local reading method, the local system still cannot correctly use the result; therefore, this embodiment uses the ability to correctly read the result locally as one of the conditions for allowing pushdown. The capability probe is executed once during metadata initialization and not re-executed when the metadata table is refreshed. The purpose is to make the scope of the probe conclusion predictable: the metadata table refresh re-acquires metadata, such as table structure and partition information, but does not reconfirm remote settings, driver return types, or pushdown capabilities; therefore, refreshing metadata is not equivalent to reconfirming capabilities. This embodiment makes pushdown eligibility determined by version conditions and actual probe testing, and makes the timing of the probe conclusion's effect clear. Ultimately, this reduces the risk of successful pushdown execution but unreadable or semantically inconsistent results; capability eligibility is obtained based on both version and actual testing, and the prohibited state is maintained when the probe fails, without releasing pushdown. Example 9

[0062] The method in this application also includes: Read the aggregation parameter expression received by the aggregation operator in the plan subtree where the original scan operator is located; If the column referenced by the aggregation parameter expression is a temporary column generated by the projection from the plan subtree where the original scan operator is located, rather than a physical column of the source table, then the following actions are performed to restore the temporary column to a physical column of the source table, and the restored expression is placed into the check condition set as a check condition: Collect and record the projection mapping of the planned subtree where the original scan operator is located; The temporary column referenced by the aggregate parameter expression is recursively expanded along the projection map, and the temporary column is successively converted into the actual transformation expression, function expression or other expression to generate the restoration expression; During the recursive expansion process, record the columns being expanded; When expanding to the same column that has already been recorded but has not yet been fully expanded, the same column will not be expanded again and a stop expansion flag will be written. The translation entry is called to perform translation on the restoration expression, and its query fragments or null value markers are recorded so that the projection temporary column name is not used as the source table column name in the assembly. References that still cannot be mapped to a column in the source table after the expansion is stopped are recorded as null values.

[0063] In one embodiment of this application, the column referenced by the aggregation parameter may not be a physical column of the source table, but a temporary column generated by projection. The temporary column is a column reference in the plan, but its actual content is an expression, such as a type conversion expression, function expression, or other expression. If the name of the temporary column is directly used as the source table column name for assembly, the name referenced by the generated query fragment may not exist remotely, or its semantics may differ from the actual expression. For example, it may generate an aggregation expression resembling the result of a type conversion, but actually reference a column named after the conversion. Therefore, it is necessary to first collect the projection mappings in the plan subtree, recursively restore the temporary column to its actual expression along the mapping, and then hand it over to the translation entry point for processing.

[0064] Projection mapping can form closed loops, where a temporary column, after several layers of projection, eventually returns to the original column. If the expansion doesn't stop, the recursive process won't terminate. Therefore, during the recursive process, the column being expanded is recorded. When the expansion reaches the same previously recorded but not yet fully expanded column again, it stops. Stopping expansion is merely a termination action and doesn't equate to successful restoration: if a reference to the source table column cannot be mapped after stopping expansion, it means the reference cannot be restored to an expression that can be expressed on the remote end, so it's marked as null and participates in the integrity determination according to the criteria. This embodiment ensures that when aggregate parameters reference projected temporary columns, the translation object is the actual expression, not the temporary column name; it allows the recursive restoration process to terminate even with loops. Ultimately, it avoids generating query fragments that reference names that don't exist on the remote end or have semantically mismatched values; references from loop projections are explicitly recorded as null values, thus entering the integrity determination process instead of being allowed as acceptable conditions. Example 10

[0065] like Figure 2 As shown, this application also proposes a predicate pushdown correctness guarantee system for multi-source heterogeneous queries under a data weaving platform, applied to the optimization stage of a distributed query engine, including: The inspection analysis module is used to obtain the query execution plan of the union query statement, determine the predicate conditions to be pushed down to the target external data source for execution, and the inspection conditions that will be revoked along with the query statement generated in this rewrite. The inspection conditions include filtering predicates, row restriction conditions and join conditions. Set building module: Used to generate a set of test conditions based on the test conditions; Translation module: Used to read the conditions in the set of conditions to be inspected one by one, and call the same translation entry as the generated query statement for each condition; Validation module: Used to read the relation alias referenced by the condition, and the type of the input field referenced by the condition in the target external data source, to determine the translation result of the condition. The translation result is a query fragment, or if it fails to be translated, it is marked and stored as a null value that is different from the value of the query fragment. The judgment and replacement module is used to determine whether all conditions in the checked condition set have yielded the query fragment; If so, a query statement is generated to replace the original scan operator in the query execution plan, the query statement is bound to the replacement scan operator, and the local bearer position of the checked condition on the original scan operator is cancelled. The local bearer position is the local scan predicate attached to the original scan operator. If not, then no query execution plan will be generated or replaced.

[0066] Each of the above modules corresponds one-to-one with each action in Embodiment 1. Their technical content and working principle are the same as those of the corresponding actions in Embodiment 1. Their execution process will not be described in detail here. It should be understood that the above module division method does not constitute a limitation on the present invention. The processing corresponding to each module can also be implemented by different logic segments of the same processing unit.

[0067] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform, applied to the optimization stage of a distributed query engine, and executed by the distributed query engine, characterized in that... include: Obtain the query execution plan of the union query statement, determine the predicate conditions to be pushed down to the target external data source for execution, and the checked conditions that will be revoked along with the query statement generated in this rewrite. The checked conditions include filtering predicates, row restriction conditions and join conditions. Based on the tested conditions, a set of tested conditions is generated; Read each condition in the set of conditions to be inspected one by one, and call the same translation entry point used to generate the query statement for each condition; Read the relation alias referenced by the condition and the type of the input field referenced by the condition in the target external data source, determine the translation result of the condition, and the translation result is a query fragment or, if it fails to be translated, a null value that is different from the value of the query fragment and stored. Determine whether all conditions in the tested condition set yield the query fragment; If so, the query statement is generated to replace the original scan operator in the query execution plan, the query statement is bound to the replacement scan operator, and the local bearer position of the checked condition on the original scan operator is revoked, where the local bearer position is the local scan predicate attached to the original scan operator. If not, then do not generate or replace the query execution plan, and output the query execution plan.

2. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 1, characterized in that, The invocation of the same translation entry point as the generation of the query statement includes: Read the left and right inputs of the plan subtree where the original scan operator is located in the query execution plan, bind the left input as a left relation alias, and bind the right input as a right relation alias; For the filtering predicate input on the left, call the left-hand relation alias to perform translation and record the translation result; For the filter predicate input on the right, call the right-side relation alias to perform translation and record the translation result; For the join condition of the join operator and the predicate attached to the join operator itself, translation is performed using the relation alias group formed by the left-hand relation alias and the right-hand relation alias, and the translation result is recorded; wherein, The translation entry point called by the translation is the same entry point called by the translation entry point used to generate the query statement, rather than a general expression generation entry point without relational aliases; The tested conditions are carried in the form of a scalar expression tree; wherein... The nodes of the scalar expression tree carry the operator type and engine type, and the child nodes of the scalar expression tree express column references, constants, comparisons, logical AND, logical OR, negation, IN, LIKE, null value judgment, CAST, CASE WHEN and function calls; Read the names that can be referenced within the current input scope, and determine the column names that can be referenced under the relation alias based on the names that can be referenced.

3. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 1, characterized in that, The step of reading each condition in the set of inspected conditions one by one and calling the same translation entry point used to generate the query statement for each condition includes: For each condition in the set of tested conditions, perform a logical AND decomposition to obtain the conjunctive set of the conditions; For each conjunct in the set of conjuncts, first read the target dialect used by the target external data source and the type context of the columns referenced by the conjunct, then call the translation entry to convert the conjunct into a query fragment, and execute the recording according to the conversion result: If the conjunction is successfully transformed, the query fragment obtained by the transformation of the conjunction is recorded; if the conjunction exists but cannot be transformed, a null value is written to the conjunction. If the condition, after the split, does not contain any conjunction terms, then the condition record set is empty; where, The null value marker and the empty set are recorded as different values ​​from each other, so that when judging and reading the null value marker and the empty set, the condition can be distinguished as either a case where no conjunctive terms are generated or a case where conjunctive terms exist but cannot be translated.

4. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 3, characterized in that, For each conjunct item obtained by splitting each condition in the set of tested conditions, the type context of the column referenced by the conjunct item includes a first purpose and a second purpose; wherein... The first purpose is performed by the following actions: Read the original type name from the driver report and retain the original type name alongside the normalized generic type from the data weaving platform. For primitive type names with type wrappers, first remove the type wrappers, then perform normalization on the primitive type names after removing the wrappers in sequence, including removing quotes, converting to lowercase, removing type parameter parentheses, and removing pattern prefixes, and record the normalized primitive type names. Read the target dialect used by the target external data source and the specific form of the conjunction. Perform a joint comparison between the normalized original type name and the target dialect and the specific form of the conjunction. If the normalized original type name matches a special string type under the target dialect and the conjunction is a comparison between a column and a string, or a LIKE or IN form, then the translation result of the conjunction is determined to be a failure, and a null value flag is written to the conjunction. Otherwise, the translation result of the conjunctive terms is retained; The second purpose is performed by the following actions: Read the engine type of the column referenced by the other operand in the comparison condition that is opposite to the constant operand, and use the read engine type as the target type; The constant operands are written according to the target type and the target dialect; wherein... For date and time types, in the standard dialect, write a string literal with quotes and escaped inner quotes; in the Oracle dialect, write it in the form of TO_DATE or TO_TIMESTAMP respectively. If the constant operand itself is a string type, then the basic translation result of the constant operand is retained; The first purpose and the second purpose read different types of sources.

5. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 1, characterized in that, The step of replacing the original scan operator in the query execution plan with an alternative scan operator also includes: When establishing the output of the query statement for the plan subtree where the original scan operator is located, an ordered output contract is generated; wherein, the output contract is written into the output items arranged in order and the retrieval mapping between each output item and the column reference operator in the plan subtree, and each output item is written with column reference, column object, remote alias and sequence number; When constructing the output contract, verify that the output items are not empty, the sequence numbers are consecutive, the column references are not repeated, and the remote aliases are not repeated after ignoring case, and record the verification results. According to the order of the output contracts, write the remote aliases sequentially to the SELECT output columns of the query statement; When setting the query statement for the alternative scan operator, verify whether the output contract matches the scan column metadata and record the matching result; During the execution plan construction phase, the scan column slots on the target external data source side are established in the order of the same output contract, so that the remote output column order corresponds to the local receiving column order. If the column referenced by the filtering predicate is not in the final output column, the filtering is first completed at the source relation level, and then the projection is performed on the required output column to establish a new output contract. For objects to be combined that only have the query statement text written but no output contract to be combined, output the query execution plan.

6. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 1, characterized in that, The determination of the inspected conditions and the generation of the query statement when all conditions yield query fragments also involve performing the following semantic position constraint actions: For the filtering predicate and the row restriction condition of the outer table scan operator, the original level of the input corresponding to the outer table scan operator is read, and the filtering predicate and the row restriction condition are executed according to the original level, so that the filtering predicate is executed before the original row restriction condition of the input, while the new filtering predicate for the already restricted remote relation is written after the row restriction condition for execution; wherein, the order of the row restriction condition and the filtering predicate in the original level remains unchanged; For outer joins, read the original filtering predicate input on the side with the padded null value, so that the original filtering predicate is executed before the padded null value is filled and is not migrated to the filtering level above the rewritten join; Read the conditions across both sides, determine and bind the equivalence conditions across both sides as equi-join keys, do not generate or replace the unsupported cross-side residual conditions, and output the query execution plan. If the required equi-join key is missing, do not generate or replace it, and output the query execution plan. In the aggregate join pushdown path with an inner join type, the query statement is generated only for the plan subtree where the original scan operator with an inner join type is located. If the join type is not an inner join, it is not generated or replaced, and the query execution plan is output.

7. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 5, characterized in that, The method further includes: The output contract and the query statement are recorded together as the execution conditions required for execution on the target external data source side; When the original scan operator contains an outer join that needs to be executed with null-padding semantics at the remote end, and other remote relation combinations are superimposed on it, the execution settings for instructing the target external data source to execute the outer join with null-padding semantics are obtained. The execution settings are merged from the lower-level input upwards, passed to the scan operator on the target external data source side through the alternative scan operator, and the execution settings are appended to the query statement in the form of a setting statement. This ensures that the execution requirements of the nested outer join for null-padding semantics are preserved, rather than just the query statement text.

8. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 1, characterized in that, Before determining whether all conditions in the tested condition set yield the query fragment, the method further includes: Perform capability probing on the target external data source; wherein, the capability probing includes: The ability to detect the external data source of the target is initially set to a disabled state; Read the version of the target external data source, compare whether the version meets the preset version conditions, and record the version comparison result; Perform actual detection on the capability to be detected and record the detection results; wherein, the actual detection includes an execution check and a result contract check, the execution check verifies whether the detection statement is executable, and the result contract check, based on the executableness of the detection statement, further verifies whether the value form or result set of its returned result corresponds to the value method and expected semantics used when reading the result of the target external data source locally; If the version comparison result indicates that the version meets the preset version condition and the detection result indicates that the actual detection meets the preset detection requirements, then the capability to be detected is written as an allowed state and the corresponding conditions are pushed down accordingly. If the version comparison result indicates that the version does not meet the preset version conditions, or if the detection result indicates that the actual detection does not meet the preset detection requirements, then the prohibited state of the capability to be detected is retained; wherein, The capability detection is performed once during metadata initialization, and is not re-executed when the metadata table is refreshed.

9. The method for ensuring the correctness of predicate pushdown in multi-source heterogeneous queries under a data weaving platform according to claim 3, characterized in that, The method further includes: Read the aggregation parameter expression received by the aggregation operator in the plan subtree where the original scan operator is located; If the column referenced by the aggregation parameter expression is a temporary column generated by the projection in the plan subtree where the original scan operator is located, rather than a physical column of the source table, then the following actions are performed to restore the temporary column to a physical column of the source table, and the restored expression is placed into the set of checked conditions as a checked condition: Collect and record the projection mapping of the planned subtree where the original scan operator is located; The temporary column referenced by the aggregation parameter expression is recursively expanded along the projection mapping, and the temporary column is successively converted into the actual transformation expression, function expression or other expression to generate the restoration expression; During the recursive expansion process, the columns being expanded are recorded; When expanding to the same column that has already been recorded but has not yet been fully expanded, the same column is not expanded again and a stop-expansion flag is written. The translation entry is called to perform translation on the restored expression, and its query fragments or null value markers are recorded so that the projection temporary column name is not used as the source table column name in the assembly. References that still cannot be mapped to a column in the source table after the expansion is stopped are recorded as null values.

10. A predicate pushdown correctness assurance system for multi-source heterogeneous queries under a data weaving platform, applied in the optimization stage of a distributed query engine, characterized in that... include: The inspection analysis module is used to obtain the query execution plan of the joint query statement, determine the predicate conditions to be pushed down to the target external data source for execution, and the inspection conditions that will be revoked along with the query statement generated in this rewrite. The inspection conditions include filtering predicates, row restriction conditions and join conditions. Set construction module: used to generate a set of test conditions based on the test conditions; Translation module: Used to read the conditions in the set of conditions to be inspected one by one, and call the same translation entry point as the one used to generate the query statement for each condition; Verification module: used to read the relation alias referenced by the condition and the type of the input field referenced by the condition in the target external data source, determine the translation result of the condition, the translation result being a query fragment, or, if translation fails, a null value that is different from the value of the query fragment and stored. The judgment and replacement module is used to determine whether all conditions in the tested condition set have yielded the query fragment; If so, the query statement is generated to replace the original scan operator in the query execution plan, the query statement is bound to the replacement scan operator, and the local bearer position of the checked condition on the original scan operator is revoked, where the local bearer position is the local scan predicate attached to the original scan operator. If not, then do not generate or replace the query execution plan, and output the query execution plan.