pg_sql_executors.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.output_consistency.execution.evaluation_strategy import (
  10. EvaluationStrategy,
  11. EvaluationStrategyKey,
  12. )
  13. from materialize.output_consistency.execution.sql_executor import SqlExecutor
  14. from materialize.output_consistency.execution.sql_executors import SqlExecutors
  15. class PgSqlExecutors(SqlExecutors):
  16. def __init__(self, mz_executor: SqlExecutor, pg_executor: SqlExecutor):
  17. super().__init__(mz_executor)
  18. self.pg_executor = pg_executor
  19. def get_executor(self, strategy: EvaluationStrategy) -> SqlExecutor:
  20. if strategy.identifier == EvaluationStrategyKey.POSTGRES:
  21. return self.pg_executor
  22. return super().get_executor(strategy)
  23. def get_database_infos(self) -> str:
  24. return (
  25. f"Using {self.executor.name} in version '{self.executor.query_version()}'. "
  26. f"Using {self.pg_executor.name} in version '{self.pg_executor.query_version()}'."
  27. )