Skip to content

Commit 4d43ac5

Browse files
rdhyeeclaude
andcommitted
Fix combined query column ambiguity error
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 <noreply@anthropic.com>
1 parent 1e4a473 commit 4d43ac5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

tutorials/parquet_cesium.qmd

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,9 @@ async function get_samples_at_geo_cord_location_via_sample_event(pid) {
348348
SELECT DISTINCT
349349
s.pid as sample_pid,
350350
s.label as sample_label,
351-
s.description as sample_description,
352-
s.thumbnail_url,
353-
s.alternate_identifiers,
351+
s.name as sample_name,
354352
event.label as event_label,
353+
event.pid as event_pid,
355354
site.label as site_label,
356355
site.pid as site_pid,
357356
'direct_event_location' as location_path
@@ -373,10 +372,9 @@ async function get_samples_at_geo_cord_location_via_sample_event(pid) {
373372
SELECT DISTINCT
374373
s.pid as sample_pid,
375374
s.label as sample_label,
376-
s.description as sample_description,
377-
s.thumbnail_url,
378-
s.alternate_identifiers,
375+
s.name as sample_name,
379376
event.label as event_label,
377+
event.pid as event_pid,
380378
site.label as site_label,
381379
site.pid as site_pid,
382380
'via_site_location' as location_path
@@ -393,7 +391,7 @@ async function get_samples_at_geo_cord_location_via_sample_event(pid) {
393391
AND g.otype = 'GeospatialCoordLocation'
394392
AND g.pid = ?
395393
396-
ORDER BY thumbnail_url IS NOT NULL DESC, sample_label
394+
ORDER BY sample_label
397395
`;
398396
const result = await loadData(q, [pid, pid], "loading_combined", "samples_combined");
399397
return result ?? [];
@@ -697,15 +695,14 @@ ${JSON.stringify(samples_2, null, 2)}
697695

698696
<div id="loading_combined" hidden>Loading combined samples…</div>
699697

700-
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:
698+
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:
701699

702-
- Sample metadata: `sample_pid`, `sample_label`, `sample_description`
703-
- Visual assets: `thumbnail_url`, `alternate_identifiers`
704-
- Event context: `event_label`
705-
- Site information: `site_label`, `site_pid` (when available)
700+
- Sample metadata: `sample_pid`, `sample_label`, `sample_name`
701+
- Event context: `event_label`, `event_pid`
702+
- Site information: `site_label`, `site_pid` (when available via Path 2)
706703
- Path indicator: `location_path` (direct_event_location or via_site_location)
707704

708-
Results are ordered with samples that have thumbnails first, making it easier to find visually rich records.
705+
Results are ordered alphabetically by sample label.
709706

710707
```{ojs}
711708
//| echo: false

0 commit comments

Comments
 (0)