trulens: [BUG]SQL Execution Canceled During INSERT Operation in Snowflake

Bug Description What happened? An unexpected error occurs while attempting to execute an INSERT operation in Snowflake using snowflake-connector. The transaction is canceled with a ProgrammingError, citing that the transaction is being committed, and SQL execution is canceled.

To Reproduce Which steps should someone take to run into the same error? A small, reproducible code example is useful here. Unfortunately, I cannot reliably reproduce the error myself as it happens intermittently. However, it occurs quite often during execution.

Expected behavior A clear and concise description of what you expected to happen. The data should be successfully saved into Snowflake without any errors.

Relevant Logs/Tracebacks Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. If the issue is related to the TruLens dashboard, please also include a screenshot.

`un unexpected error occurred: (snowflake.connector.errors.ProgrammingError) 000614 (57014): 01b99a49-0512-a1e0-0074-820306b2185a: Transaction ‘5c518634-c4c0-471c-8d8a-bd20b4dd453e’, id ‘1736452409002000000’, was committed, SQL execution canceled. [SQL: INSERT INTO trulens_records (record_id, app_id, input, output, record_json, tags, ts, cost_json, perf_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)]

(Background on this error at: https://sqlalche.me/e/20/f405)`

Environment:

  • OS: [e.g. MacOS, Windows]
  • Python Version
  • TruLens version
  • Versions of other relevant installed libraries

Additional context Add any other context about the problem here.

`def initialize_sessions(sf_settings: dict, password: str) -> Tuple[Session, TruSession]: “”" Initialize Snowpark session and TruLens session. “”" sf_config = sf_settings.copy() sf_config.update({ “connection_timeout”: 300, # 5 minutes “client_session_keep_alive”: True, “session_timeout”: 600 # 10 minutes })

# Create Snowpark session
snowpark_session = Session.builder.configs(sf_settings).create()
print("Snowpark session created successfully.")

# Initialize SnowflakeConnector for TruLens
conn = SnowflakeConnector(
    snowpark_session=snowpark_session,
    password=password,
    database_redact_keys=True
)

# Create TruSession
session = TruSession(connector=conn)
# session.reset_database()
print("TruSession initialized and database reset.")
return snowpark_session, session

with tru_app: response = retrieval_app.ask_question( query=qa.get(“question”), ) print(f"Response: {response}") `

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (8 by maintainers)

Most upvoted comments

trulens_sf.zip @sfc-gh-jreini Sorry. Here is the additional code where I set up ConversationalRetrievalAgent.

https://github.com/truera/trulens/issues/1717 I also have this NaN issue from the same code.

are you using SQL to call Snowflake Cortex in your app? That may be the cause here. Can you change it to use the python API?

Thank you for your response! I believe I am already using the Python API to interact with Snowflake. Specifically, I am using the SnowflakeConnector class from trulens.connectors.snowflake

` snowpark_session = Session.builder.configs(sf_settings).create() print(“Snowpark session created successfully.”)

conn = SnowflakeConnector(
    snowpark_session=snowpark_session,
    password=password,
    database_redact_keys=True
)

session = TruSession(connector=conn)
return snowpark_session, session

`