- {queryAttachments.map((att) => (
-
-
-
- {att.query?.title ?? "SQL Query"}
-
-
- {att.query?.description && (
-
- {att.query.description}
-
- )}
- {att.query?.query && (
-
- {att.query.query}
-
- )}
-
-
-
- ))}
+ {queryAttachments.map((att) => {
+ const key = att.attachmentId ?? "query";
+ const queryResult = att.attachmentId
+ ? message.queryResults.get(att.attachmentId)
+ : undefined;
+
+ return (
+
+
+
+
+ {att.query?.title ?? "SQL Query"}
+
+
+ {att.query?.description && (
+
+ {att.query.description}
+
+ )}
+ {att.query?.query && (
+
+ {att.query.query}
+
+ )}
+
+
+
+ {queryResult != null && (
+
+
+
+ )}
+
+ );
+ })}
)}
diff --git a/packages/appkit-ui/src/react/genie/genie-query-transform.ts b/packages/appkit-ui/src/react/genie/genie-query-transform.ts
new file mode 100644
index 00000000..6db50902
--- /dev/null
+++ b/packages/appkit-ui/src/react/genie/genie-query-transform.ts
@@ -0,0 +1,118 @@
+/**
+ * Converts Genie's statement_response data into a flat record array
+ * suitable for charting.
+ *
+ * The Genie API returns `{ manifest.schema.columns, result.data_array }`
+ * where each column carries a SQL `type_name`. This module parses values
+ * according to those types so downstream chart code receives proper
+ * numbers and strings.
+ */
+
+// SQL type_name values that map to numeric JS values
+const NUMERIC_SQL_TYPES = new Set([
+ "DECIMAL",
+ "INT",
+ "INTEGER",
+ "BIGINT",
+ "LONG",
+ "SMALLINT",
+ "TINYINT",
+ "FLOAT",
+ "DOUBLE",
+ "SHORT",
+ "BYTE",
+]);
+
+// SQL type_name values that map to date/timestamp strings
+const DATE_SQL_TYPES = new Set(["DATE", "TIMESTAMP", "TIMESTAMP_NTZ"]);
+
+export type ColumnCategory = "numeric" | "date" | "string";
+
+export interface GenieColumnMeta {
+ name: string;
+ typeName: string;
+ category: ColumnCategory;
+}
+
+export interface TransformedGenieData {
+ rows: Record