Skip to content

Commit

Permalink
remove snowflake
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-gtokernliang committed Dec 19, 2024
1 parent 1e3ace1 commit 049b404
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
18 changes: 1 addition & 17 deletions examples/experimental/otel_exporter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,13 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"import dotenv\n",
"from trulens.connectors.snowflake import SnowflakeConnector\n",
"from trulens.core.session import TruSession\n",
"from trulens.experimental.otel_tracing.core.init import init\n",
"\n",
"dotenv.load_dotenv()\n",
"\n",
"connection_params = {\n",
" \"account\": os.environ[\"SNOWFLAKE_ACCOUNT\"],\n",
" \"user\": os.environ[\"SNOWFLAKE_USER\"],\n",
" \"password\": os.environ[\"SNOWFLAKE_USER_PASSWORD\"],\n",
" \"database\": os.environ[\"SNOWFLAKE_DATABASE\"],\n",
" \"schema\": os.environ[\"SNOWFLAKE_SCHEMA\"],\n",
" \"warehouse\": os.environ[\"SNOWFLAKE_WAREHOUSE\"],\n",
" \"role\": os.environ[\"SNOWFLAKE_ROLE\"],\n",
"}\n",
"\n",
"connector = SnowflakeConnector(\n",
" **connection_params, database_redact_keys=True, database_args=None\n",
")\n",
"session = TruSession(connector=connector)\n",
"session = TruSession()\n",
"session.reset_database()\n",
"init(session, debug=True)"
]
Expand Down
47 changes: 0 additions & 47 deletions src/core/trulens/core/database/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
import pandas as pd
import pydantic
from pydantic import Field
from snowflake.sqlalchemy import dialect as SnowflakeDialect
import sqlalchemy as sa
from sqlalchemy import Table
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql import text as sql_text
from sqlalchemy.sql.compiler import SQLCompiler
from sqlalchemy.sql.expression import Insert
from trulens.core.database import base as core_db
from trulens.core.database import exceptions as db_exceptions
from trulens.core.database import migrations as db_migrations
Expand All @@ -57,49 +53,6 @@
logger = logging.getLogger(__name__)


@compiles(Insert, SnowflakeDialect.name)
def patch_insert(statement: Insert, compiler: SQLCompiler, **kw):
"""
Patches INSERT SQL queries so sqlalchemy ORM will support Snowflake OBJECT.
See:
* https://github.com/snowflakedb/snowflake-sqlalchemy/issues/299
* https://github.com/snowflakedb/snowflake-sqlalchemy/issues/411
For more information (e.g. read about the parameters), please look at:
* https://docs.sqlalchemy.org/en/20/core/compiler.html
"""
insert_statement = compiler.visit_insert(statement, **kw)

if statement.table.name.endswith("_events"):
insert_statement = insert_statement.replace(
"VALUES (%(record)s, %(event_id)s, %(record_attributes)s, %(record_type)s, %(resource_attributes)s, %(start_timestamp)s, %(timestamp)s, %(trace)s)",
"""
SELECT
PARSE_JSON(column1),
column2,
PARSE_JSON(column3),
column4,
PARSE_JSON(column5),
column6,
column7,
PARSE_JSON(column8),
from VALUES (
%(record)s,
%(event_id)s,
%(record_attributes)s,
%(record_type)s,
%(resource_attributes)s,
%(start_timestamp)s,
%(timestamp)s,
%(trace)s
)
""",
)

return insert_statement


class SnowflakeImpl(DefaultImpl):
__dialect__ = "snowflake"

Expand Down

0 comments on commit 049b404

Please sign in to comment.