Skip to content

[Trex] add session variables for TREX HANA sql execution#181

Open
Zhimin-arya wants to merge 2 commits into
OHDSI:developfrom
Zhimin-arya:Zhimin-arya/session_variables
Open

[Trex] add session variables for TREX HANA sql execution#181
Zhimin-arya wants to merge 2 commits into
OHDSI:developfrom
Zhimin-arya:Zhimin-arya/session_variables

Conversation

@Zhimin-arya

Copy link
Copy Markdown

No description provided.



getConnection(db_id, schema, vocab_schema, result_schema, translationMap) {
getConnection(db_id, schema, vocab_schema, result_schema, translationMap, sessionVariables = {}) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow callers such as parquet-export to provide session variables

}
}

fn parse_session_vars(json: &str) -> Result<BTreeMap<String, String>, Box<dyn Error>> {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fn is copied from hana_materialize.rs using same logic to set application session variable

}
let (column_names, column_types, temporal_cols) = match safe_hana_connect(url.clone()) {
Ok(connection) => {
apply_session_vars(&connection, &session_vars)?;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply variables to the schema-detection connection

for attempt in 0..=bind_data_ref.max_retries {
match safe_hana_connect(bind_data_ref.url.clone()) {
Ok(connection) => {
apply_session_vars(&connection, &bind_data_ref.session_vars)?;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply variables to the execution connection

duckdb::core::LogicalTypeHandle::from(LogicalTypeId::Varchar),
])
}
fn named_parameters() -> Option<Vec<(String, duckdb::core::LogicalTypeHandle)>> {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named_parameters() tells DuckDB:
trex_hana_scan accepts an optional input called session_vars_json, and its value must be text.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 4.34783% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.62%. Comparing base (a649ca6) to head (3c2f511).
⚠️ Report is 8 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #181      +/-   ##
===========================================
- Coverage    52.66%   52.62%   -0.04%     
===========================================
  Files          168      168              
  Lines        72584    72630      +46     
===========================================
- Hits         38223    38219       -4     
- Misses       34361    34411      +50     
Flag Coverage Δ
unit-chdb 31.39% <ø> (ø)
unit-db 70.65% <ø> (ø)
unit-etl 56.82% <ø> (ø)
unit-fhir 66.57% <ø> (ø)
unit-hana 41.85% <4.34%> (-1.18%) ⬇️
unit-migration 20.89% <ø> (ø)
unit-pg_trex 17.74% <ø> (ø)
unit-pgt 93.04% <ø> (ø)
unit-pgwire 67.34% <ø> (ø)
unit-runtime 45.83% <ø> (ø)
unit-tpm 69.03% <ø> (ø)
unit-transform 70.85% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Successfully merging this pull request may close these issues.

1 participant