Spaces:
Running
Running
view-data: cast every to_json wrap to VARCHAR
Browse filesDuckDB's to_json() returns the `JSON` type, which is a VARCHAR alias
with an extra logical-type tag. The deployed Space's linux-x64 binding
still threw "Invalid Error: don't know what type:" after the
previous patch because that JSON tag — not the underlying string —
is what the binding's type-switch falls through on. Explicitly cast
each wrap to plain VARCHAR so the binding sees a primitive it
already handles.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- lib/view-data.ts +22 -15
lib/view-data.ts
CHANGED
|
@@ -68,7 +68,8 @@ const EVAL_LIST_COLUMNS = `
|
|
| 68 |
metric_config, models_count, evaluator_names, source_types,
|
| 69 |
latest_source_name, third_party_ratio,
|
| 70 |
missing_generation_config_count, best_model, worst_model,
|
| 71 |
-
avg_score, avg_score_norm, has_card,
|
|
|
|
| 72 |
is_aggregated, aggregate_sources, tags,
|
| 73 |
metrics_count, metric_names, instance_data, top_score,
|
| 74 |
subtasks_count, is_summary_score, summary_eval_ids,
|
|
@@ -85,17 +86,23 @@ const EVAL_LIST_COLUMNS = `
|
|
| 85 |
// `to_json(...)` so the binding only ever sees VARCHAR per row;
|
| 86 |
// `parseMaybeJson` undoes the wrap in JS before downstream code
|
| 87 |
// reads the shapes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
const CELL_JOIN_COLUMNS = `
|
| 89 |
r.* REPLACE (
|
| 90 |
-
to_json(r.model_info) AS model_info,
|
| 91 |
-
to_json(r.generation_config) AS generation_config,
|
| 92 |
-
to_json(r.score_details) AS score_details,
|
| 93 |
-
to_json(r.source_metadata) AS source_metadata,
|
| 94 |
-
to_json(r.source_data) AS source_data,
|
| 95 |
-
to_json(r.eval_library) AS eval_library,
|
| 96 |
-
to_json(r.aggregate_components) AS aggregate_components,
|
| 97 |
-
to_json(r.evalcards_annotations) AS evalcards_annotations,
|
| 98 |
-
to_json(r.scores_by_organization) AS scores_by_organization
|
| 99 |
),
|
| 100 |
e.evaluation_name AS eval_evaluation_name,
|
| 101 |
e.canonical_display_name AS eval_canonical_display_name,
|
|
@@ -110,10 +117,10 @@ const CELL_JOIN_COLUMNS = `
|
|
| 110 |
e.composite_display_name AS eval_composite_benchmark_name,
|
| 111 |
e.family_display_name AS eval_benchmark_family_name,
|
| 112 |
e.category AS eval_category,
|
| 113 |
-
to_json(e.metric_config) AS eval_metric_config,
|
| 114 |
-
to_json(e.source_data) AS eval_source_data,
|
| 115 |
-
to_json(e.benchmark_card) AS eval_benchmark_card,
|
| 116 |
-
to_json(e.tags) AS eval_tags,
|
| 117 |
e.is_summary_score AS eval_is_summary_score,
|
| 118 |
e.summary_eval_ids AS eval_summary_eval_ids
|
| 119 |
`
|
|
@@ -775,7 +782,7 @@ export async function getBenchmarkMetadataMap(): Promise<Record<string, Benchmar
|
|
| 775 |
`SELECT evaluation_id, evaluation_name,
|
| 776 |
family_id AS composite_benchmark_key,
|
| 777 |
benchmark_id,
|
| 778 |
-
to_json(benchmark_card) AS benchmark_card
|
| 779 |
FROM evals_view
|
| 780 |
WHERE benchmark_card IS NOT NULL`
|
| 781 |
)
|
|
|
|
| 68 |
metric_config, models_count, evaluator_names, source_types,
|
| 69 |
latest_source_name, third_party_ratio,
|
| 70 |
missing_generation_config_count, best_model, worst_model,
|
| 71 |
+
avg_score, avg_score_norm, has_card,
|
| 72 |
+
CAST(to_json(benchmark_card) AS VARCHAR) AS benchmark_card,
|
| 73 |
is_aggregated, aggregate_sources, tags,
|
| 74 |
metrics_count, metric_names, instance_data, top_score,
|
| 75 |
subtasks_count, is_summary_score, summary_eval_ids,
|
|
|
|
| 86 |
// `to_json(...)` so the binding only ever sees VARCHAR per row;
|
| 87 |
// `parseMaybeJson` undoes the wrap in JS before downstream code
|
| 88 |
// reads the shapes.
|
| 89 |
+
// Note the `::VARCHAR` cast on every to_json wrap. `to_json()` returns
|
| 90 |
+
// DuckDB's `JSON` type, which is a VARCHAR alias with extra metadata —
|
| 91 |
+
// the linux-x64 binding interprets that metadata tag as its own
|
| 92 |
+
// (unsupported) type and still throws "don't know what type:" on row
|
| 93 |
+
// materialisation. Casting to plain VARCHAR strips the tag so the
|
| 94 |
+
// binding sees the same primitive type it handles everywhere else.
|
| 95 |
const CELL_JOIN_COLUMNS = `
|
| 96 |
r.* REPLACE (
|
| 97 |
+
CAST(to_json(r.model_info) AS VARCHAR) AS model_info,
|
| 98 |
+
CAST(to_json(r.generation_config) AS VARCHAR) AS generation_config,
|
| 99 |
+
CAST(to_json(r.score_details) AS VARCHAR) AS score_details,
|
| 100 |
+
CAST(to_json(r.source_metadata) AS VARCHAR) AS source_metadata,
|
| 101 |
+
CAST(to_json(r.source_data) AS VARCHAR) AS source_data,
|
| 102 |
+
CAST(to_json(r.eval_library) AS VARCHAR) AS eval_library,
|
| 103 |
+
CAST(to_json(r.aggregate_components) AS VARCHAR) AS aggregate_components,
|
| 104 |
+
CAST(to_json(r.evalcards_annotations) AS VARCHAR) AS evalcards_annotations,
|
| 105 |
+
CAST(to_json(r.scores_by_organization) AS VARCHAR) AS scores_by_organization
|
| 106 |
),
|
| 107 |
e.evaluation_name AS eval_evaluation_name,
|
| 108 |
e.canonical_display_name AS eval_canonical_display_name,
|
|
|
|
| 117 |
e.composite_display_name AS eval_composite_benchmark_name,
|
| 118 |
e.family_display_name AS eval_benchmark_family_name,
|
| 119 |
e.category AS eval_category,
|
| 120 |
+
CAST(to_json(e.metric_config) AS VARCHAR) AS eval_metric_config,
|
| 121 |
+
CAST(to_json(e.source_data) AS VARCHAR) AS eval_source_data,
|
| 122 |
+
CAST(to_json(e.benchmark_card) AS VARCHAR) AS eval_benchmark_card,
|
| 123 |
+
CAST(to_json(e.tags) AS VARCHAR) AS eval_tags,
|
| 124 |
e.is_summary_score AS eval_is_summary_score,
|
| 125 |
e.summary_eval_ids AS eval_summary_eval_ids
|
| 126 |
`
|
|
|
|
| 782 |
`SELECT evaluation_id, evaluation_name,
|
| 783 |
family_id AS composite_benchmark_key,
|
| 784 |
benchmark_id,
|
| 785 |
+
CAST(to_json(benchmark_card) AS VARCHAR) AS benchmark_card
|
| 786 |
FROM evals_view
|
| 787 |
WHERE benchmark_card IS NOT NULL`
|
| 788 |
)
|