Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crate_preprocess_rio still tries to validate the created views when the --print option is used #164

Open
martinburchell opened this issue Aug 13, 2024 · 0 comments

Comments

@martinburchell
Copy link
Collaborator

If you run the crate_preprocess_rio script with the --print option, it tries to check if the created view has the same number of rows as the table it is based on. This fails if the view doesn't exist.

We shouldn't call assert_view_has_same_num_rows() if the preprocessing script is run with the --print option.


Traceback (most recent call last):
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
    self.dialect.do_execute(
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
pyodbc.ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'Care_Plan_Index'. (208) (SQLExecDirectW)")
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/crate/venv/bin/crate_preprocess_rio", line 8, in <module>
    sys.exit(main())
  File "/crate/venv/lib/python3.8/site-packages/crate_anon/preprocess/preprocess_rio.py", line 1537, in main
    create_rio_views(engine, metadata, configoptions, ddhint)
  File "/crate/venv/lib/python3.8/site-packages/crate_anon/preprocess/preprocess_rio.py", line 1125, in create_rio_views
    viewmaker.create_view(engine)
  File "/crate/venv/lib/python3.8/site-packages/crate_anon/common/sql.py", line 1665, in create_view
    assert_view_has_same_num_rows(
  File "/crate/venv/lib/python3.8/site-packages/crate_anon/common/sql.py", line 1375, in assert_view_has_same_num_rows
    n_view = count_star(engine, viewname)
  File "<string>", line 2, in execute
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 468, in warned
    return fn(*args, **kwargs)
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3267, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1385, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 334, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1577, in _execute_clauseelement
    ret = self._execute_context(
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1953, in _execute_context
    self._handle_dbapi_exception(
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2134, in _handle_dbapi_exception
    util.raise_(
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
    self.dialect.do_execute(
  File "/crate/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'Care_Plan_Index'. (208) (SQLExecDirectW)")
[SQL: SELECT count(*) AS count_1 
FROM [Care_Plan_Index]]
(Background on this error at: https://sqlalche.me/e/14/f405)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant