Skip to content

Commit

Permalink
Clean up explain timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jkosh44 committed Aug 3, 2022
1 parent 5bd3806 commit fede456
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/adapter/src/coord/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2402,14 +2402,22 @@ impl<S: Append + 'static> Coordinator<S> {
let optimized_plan = self.view_optimizer.optimize(decorrelated_plan)?;
let timeline = self.validate_timeline(optimized_plan.depends_on())?;
let source_ids = optimized_plan.depends_on();
// Determine a timestamp that will be valid for anything in any schema
// referenced by the query.
let id_bundle = self.timedomain_for(
&source_ids,
&timeline,
session.conn_id(),
compute_instance,
)?;
let id_bundle = if session.vars().transaction_isolation()
== &IsolationLevel::StrictSerializable
&& timeline.is_some()
{
self.index_oracle(compute_instance)
.sufficient_collections(&source_ids)
} else {
// Determine a timestamp that will be valid for anything in any schema
// referenced by the query.
self.timedomain_for(
&source_ids,
&timeline,
session.conn_id(),
compute_instance,
)?
};
// TODO: determine_timestamp takes a mut self to track table linearizability,
// so explaining a plan involving tables has side effects. Removing those side
// effects would be good.
Expand Down
2 changes: 1 addition & 1 deletion test/testdrive/csv-sources.td
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ contains:Expected a list of columns in parentheses, found EOF
# since the definition of "static" means "will never change again".
$ set-regex match=(\d{13}|u\d{1,3}) replacement=<>
> EXPLAIN TIMESTAMP FOR SELECT * FROM static_csv
" timestamp: <>\n since:[<>]\n upper:[]\n has table: false\n\nsource materialize.public.mismatched_column_count (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n\nsource materialize.public.matching_column_names (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n\nsource materialize.public.matching_column_names_alias (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n\nsource materialize.public.mismatched_column_names (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n\nsource materialize.public.mismatched_column_names_count (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n\nsource materialize.public.static_csv (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n"
" timestamp: <>\n since:[<>]\n upper:[]\n has table: false\n\nsource materialize.public.static_csv (<>, storage):\n read frontier:[<>]\nwrite frontier:[]\n"

# Static CSV with manual headers.
> CREATE SOURCE static_csv_manual_header (city_man, state_man, zip_man)
Expand Down
24 changes: 24 additions & 0 deletions test/testdrive/explain-timestamps.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

$ set-regex match=(\d{13}|u\d{1,3}) replacement=<REDACTED>

> CREATE TABLE t1 (a INT);

> CREATE TABLE t2 (a INT);

# Strict serializable doesn't look at every object in the same time domain
> SET TRANSACTION_ISOLATION = 'STRICT SERIALIZABLE';
> EXPLAIN TIMESTAMP FOR SELECT * FROM t1
" timestamp: <REDACTED>\n since:[<REDACTED>]\n upper:[<REDACTED>]\n has table: true\n table read ts: <REDACTED>\n\nsource materialize.public.t1 (<REDACTED>, storage):\n read frontier:[<REDACTED>]\nwrite frontier:[<REDACTED>]\n"

# Serializable does look at every object in the same time domain
> SET TRANSACTION_ISOLATION = 'SERIALIZABLE';
> EXPLAIN TIMESTAMP FOR SELECT * FROM t1
" timestamp: <REDACTED>\n since:[<REDACTED>]\n upper:[<REDACTED>]\n has table: true\n table read ts: <REDACTED>\n\nsource materialize.public.t1 (<REDACTED>, storage):\n read frontier:[<REDACTED>]\nwrite frontier:[<REDACTED>]\n\nsource materialize.public.t2 (<REDACTED>, storage):\n read frontier:[<REDACTED>]\nwrite frontier:[<REDACTED>]\n"

0 comments on commit fede456

Please sign in to comment.