Skip to content

Commit

Permalink
fix: Use correct coordinator query types
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Jun 30, 2024
1 parent d49b737 commit bf8f2a8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/clients/DataTable.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ th {
border-bottom: solid 1px var(--light-silver);
border-left: solid 1px var(--light-silver);
padding: 5px 6px 0 6px;
user-select: none;
}

.number, .date {
Expand Down
6 changes: 5 additions & 1 deletion lib/deps/mosaic-core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ export class MosaicClient {
requestQuery(query: Query): void;
}

export type ConnectorQuery = { type: "arrow" | "json"; sql: string };

export interface Connector {
query(query: Query): Promise<arrow.Table | Record<string, unknown>>;
query(
query: ConnectorQuery,
): Promise<arrow.Table | Record<string, unknown>>;
}

export class Coordinator {
Expand Down
2 changes: 1 addition & 1 deletion lib/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DataTable } from "./clients/DataTable.ts";
let base = new URL(
"https://raw.githubusercontent.com/uwdata/mosaic/main/data/",
);
let table: keyof typeof datasets = "metros";
let table: keyof typeof datasets = "athletes";
let datasets = {
athletes: new URL("athletes.csv", base).href,
unemployment: new URL("us-county-unemployment.csv", base).href,
Expand Down
10 changes: 4 additions & 6 deletions lib/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Model = {
};

interface OpenQuery {
query: Query;
query: mc.ConnectorQuery;
startTime: number;
resolve: (x: arrow.Table | Record<string, unknown>) => void;
reject: (err?: string) => void;
Expand All @@ -38,7 +38,7 @@ export default () => {
* @param reject - the promise reject callback
*/
function send(
query: Query,
query: mc.ConnectorQuery,
resolve: (value: arrow.Table | Record<string, unknown>) => void,
reject: (reason?: string) => void,
) {
Expand Down Expand Up @@ -88,7 +88,7 @@ export default () => {
logger.groupEnd("query");
});

let connector = {
coordinator.databaseConnector({
query(query) {
let { promise, resolve, reject } = defer<
arrow.Table | Record<string, unknown>,
Expand All @@ -97,9 +97,7 @@ export default () => {
send(query, resolve, reject);
return promise;
},
} satisfies mc.Connector;

coordinator.databaseConnector(connector);
});

// get some initial data to get the schema
let empty = await coordinator.query(
Expand Down

0 comments on commit bf8f2a8

Please sign in to comment.