Skip to content

Conversation

@ditadi
Copy link
Contributor

@ditadi ditadi commented Dec 8, 2025

Summary

Add sql.* helpers for type-safe SQL query parameters. Solves the problem of agents struggling to parameterize SQL and properly cast values.

Helpers

  • sql.date() - Date objects or ISO strings → YYYY-MM-DD
  • sql.timestamp() - Date, ISO string, or Unix timestamp
  • sql.string() - String, number, or boolean
  • sql.number() - Number or numeric string
  • sql.boolean() - Boolean, string ("true"/"false"), or number (0/1)
  • sql.binary() - Uint8Array, ArrayBuffer, or hex-encoded string

Usage

  import { sql } from "@databricks/app-kit-ui/js";

  const params = {
    startDate: sql.date(new Date()),
    endDate: sql.date("2024-12-31"),
    userId: sql.number(123),
    name: sql.string("John"),
    isActive: sql.boolean(true),
  };

Notes

  • All helpers validate inputs and throw descriptive errors
  • Exports SQLTypeMarker type and isSQLTypeMarker type guard for custom integrations
  • SQL Helpers are exported from the app-kit for server and from app-kit-ui/js for the client.

@ditadi ditadi requested review from a team, MarioCadenas and fjakobs December 8, 2025 10:43
Copy link
Collaborator

@fjakobs fjakobs left a comment

Choose a reason for hiding this comment

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

Looks good. Let's just make sure that the encoding for binary parameters is correct.

.join("");
} else if (value instanceof ArrayBuffer) {
binaryValue = Array.from(new Uint8Array(value))
.map((b) => b.toString(16).padStart(2, "0").toUpperCase())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you test sending binary data. Would like to have confidence that we are encoding the data properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved the tests and added a new interactive demo showing the features + doing a real SQL test on the dev-playground.

Screen.Recording.2025-12-08.at.12.42.13.mov

@ditadi ditadi merged commit 3cddd0e into main Dec 8, 2025
3 checks passed
@MarioCadenas MarioCadenas deleted the feat/sql-param-helpers branch December 19, 2025 17:44
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.

3 participants