The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import type { Card, LegacyDatasetQuery, NativeQuery } from "metabase-types/api";
import {
type Options,
type QuestionDetails,
logAction,
question,
} from "./createQuestion";
export type NativeQuestionDetails = Omit<QuestionDetails, "dataset_query"> & {
/**
* Defaults to SAMPLE_DB_ID.
*/
database?: LegacyDatasetQuery["database"];
native: NativeQuery;
};
export const createNativeQuestion = (
questionDetails: NativeQuestionDetails,
options?: Options,
): Cypress.Chainable<Cypress.Response<Card>> => {
const { database = SAMPLE_DB_ID, name, native } = questionDetails;
if (!native) {
throw new Error('"native" attribute missing in questionDetails');
}
logAction("Create a native question", name);
return question(
{
...questionDetails,
dataset_query: { type: "native", native, database },
},
options,
);
};