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
- Provides a means to rewrite the
.sltfile while iterating over it.
- 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.
- connect 🔒
- Analyzes the provided query
bodyto derive the number of attributes in the query. We only consider syntactic cues, so we may end up deriving
Nonefor the number of attributes as a conservative approximation.
- Computes the number of attributes that are obtained by the projection of a
SELECTquery. The projection may include wildcards, in which case the analysis just returns
- Analyzes a query’s
ORDER BYclause to derive an
ORDER BYclause 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 rewritten
ORDER BYclause is then usable when querying a view that contains the same
SELECTas the given query. This function returns both the rewritten
ORDER BYclause as well as a list of extra columns that need to be added to the query’s projection for the
ORDER BYclause to succeed.
- Computes an
ORDER BYclause with only numeric references from given projection and
ORDER BYof a
SELECTquery. If the derivation fails to match a given expression, the matched prefix is returned. Note that this could be empty.
- Finds the projection list in a
- Generates view creation, view indexing, view querying, and view dropping SQL commands for a given
SELECTquery. 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_selectsand assumes that the provided input SQL has already been run through the parser, resulting in a valid
- mutate 🔒Returns extra statements to execute after
- 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.