Module mz_sqllogictest::runner
source Β· Expand description
The Materialize-specific runner for sqllogictest.
slt tests expect a serialized execution of sql statements and queries. To get the same results in materialize we track current_timestamp and increment it whenever we execute a statement.
The high-level workflow is: for each record in the test file: if record is a sql statement: run sql in postgres, observe changes and copy them to materialize using LocalInput::Updates(..) advance current_timestamp promise to never send updates for times < current_timestamp using LocalInput::Watermark(..) compare to expected results if wrong, bail out and stop processing this file if record is a sql query: peek query at current_timestamp compare to expected results if wrong, record the error
Structs§
- Query
Info π - Rewrite
Buffer πProvides a means to rewrite the.slt
file while iterating over it.
Enums§
- Prepare
Query πOutcome
Constants§
- Regular expressions for matching error messages that should force a plan failure in an inconsistent view outcome into a warning if the corresponding query succeeds.
- NUM_
OUTCOMES π - SUCCES
S_ πOUTCOME - WARNIN
G_ πOUTCOME
Traits§
Functions§
- connect π
- Analyzes the provided query
body
to derive the number of attributes in the query. We only consider syntactic cues, so we may end up derivingNone
for the number of attributes as a conservative approximation. - Computes the number of attributes that are obtained by the projection of a
SELECT
query. The projection may include wildcards, in which case the analysis just returnsNone
. - derive_
order_ πby Analyzes a queryβsORDER BY
clause to derive anORDER BY
clause that makes numeric references to any expressions in the projection and generated-attribute references to expressions that need to be added as extra columns to the projection list. The rewrittenORDER BY
clause is then usable when querying a view that contains the sameSELECT
as the given query. This function returns both the rewrittenORDER BY
clause as well as a list of extra columns that need to be added to the queryβs projection for theORDER BY
clause to succeed. - Computes an
ORDER BY
clause with only numeric references from given projection andORDER BY
of aSELECT
query. If the derivation fails to match a given expression, the matched prefix is returned. Note that this could be empty. - find_
projection πFinds the projection list in aSELECT
query body. - format_
datum π - format_
row π - generate_
view_ πsql Generates view creation, view indexing, view querying, and view dropping SQL commands for a givenSELECT
query. If the number of attributes produced by the query is known, the view commands are specialized to avoid issues with column ambiguity. This function is a helper for--auto_index_selects
and assumes that the provided input SQL has already been run through the parser, resulting in a validSELECT
statement. - mutate πReturns extra statements to execute after
stmt
is executed. - print_
record π - print_
sql π - print_
sql_ πif - read_
be_ πi32 - read_
value π - should_
warn πEvaluates if the given outcome should be returned directly or if it should be wrapped as a warning. Note that this function should be used for outcomes that can be judged in a context-independent manner, i.e., the outcome itself provides enough information as to whether a warning should be emitted or not.