From 4d43ac568d5f7acbe829a35156b4cbeb8a8c20db Mon Sep 17 00:00:00 2001 From: Raymond Yee Date: Thu, 30 Oct 2025 17:45:00 -0700 Subject: [PATCH] Fix combined query column ambiguity error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG FIX: Resolve "Ambiguous reference to column name" error in get_samples_at_geo_cord_location_via_sample_event() Problem: - Query requested s.description, s.thumbnail_url, s.alternate_identifiers - These columns don't exist on MaterialSampleRecord nodes - thumbnail_url exists on both 'event' and 'site' tables, causing ambiguity - Query was failing silently, returning empty array [] Solution: - Use only columns that exist on MaterialSampleRecord: pid, label, name - Add event.pid to match Path 1/2 queries - Remove thumbnail_url sorting (column doesn't exist on samples) - Simplify ORDER BY to just sample_label Testing: - Verified Path 1 and Path 2 queries work (they use correct columns) - Error found via browser console: document.getElementById('loading_combined').innerHTML - Error was: "Binder Error: Ambiguous reference to column name 'thumbnail_url'" Changes: - Removed: s.description, s.thumbnail_url, s.alternate_identifiers - Added: s.name, event.pid (matching working queries) - Updated documentation to reflect actual returned columns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tutorials/parquet_cesium.qmd | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tutorials/parquet_cesium.qmd b/tutorials/parquet_cesium.qmd index bbc277f..844e1bb 100644 --- a/tutorials/parquet_cesium.qmd +++ b/tutorials/parquet_cesium.qmd @@ -348,10 +348,9 @@ async function get_samples_at_geo_cord_location_via_sample_event(pid) { SELECT DISTINCT s.pid as sample_pid, s.label as sample_label, - s.description as sample_description, - s.thumbnail_url, - s.alternate_identifiers, + s.name as sample_name, event.label as event_label, + event.pid as event_pid, site.label as site_label, site.pid as site_pid, 'direct_event_location' as location_path @@ -373,10 +372,9 @@ async function get_samples_at_geo_cord_location_via_sample_event(pid) { SELECT DISTINCT s.pid as sample_pid, s.label as sample_label, - s.description as sample_description, - s.thumbnail_url, - s.alternate_identifiers, + s.name as sample_name, event.label as event_label, + event.pid as event_pid, site.label as site_label, site.pid as site_pid, 'via_site_location' as location_path @@ -393,7 +391,7 @@ async function get_samples_at_geo_cord_location_via_sample_event(pid) { AND g.otype = 'GeospatialCoordLocation' AND g.pid = ? - ORDER BY thumbnail_url IS NOT NULL DESC, sample_label + ORDER BY sample_label `; const result = await loadData(q, [pid, pid], "loading_combined", "samples_combined"); return result ?? []; @@ -697,15 +695,14 @@ ${JSON.stringify(samples_2, null, 2)} -This query implements Eric Kansa's `get_samples_at_geo_cord_location_via_sample_event` function, which combines both Path 1 and Path 2 using UNION and returns richer sample metadata including: +This query implements Eric Kansa's `get_samples_at_geo_cord_location_via_sample_event` function, which combines both Path 1 and Path 2 using UNION and returns sample metadata including: -- Sample metadata: `sample_pid`, `sample_label`, `sample_description` -- Visual assets: `thumbnail_url`, `alternate_identifiers` -- Event context: `event_label` -- Site information: `site_label`, `site_pid` (when available) +- Sample metadata: `sample_pid`, `sample_label`, `sample_name` +- Event context: `event_label`, `event_pid` +- Site information: `site_label`, `site_pid` (when available via Path 2) - Path indicator: `location_path` (direct_event_location or via_site_location) -Results are ordered with samples that have thumbnails first, making it easier to find visually rich records. +Results are ordered alphabetically by sample label. ```{ojs} //| echo: false