From 25da4ae1fbaf66a561e5eca6f3ac583e695777c0 Mon Sep 17 00:00:00 2001 From: Lloyd Tabb Date: Thu, 12 Dec 2024 08:00:04 -0800 Subject: [PATCH] DO NOT MERGE: hack to save code --- package.json | 3 ++- scripts/describe_cube.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 scripts/describe_cube.ts diff --git a/package.json b/package.json index 090138de9..d77d6ba0a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "third-party-licenses": "ts-node scripts/third_party_licenses", "malloyc": "ts-node scripts/malloy-to-json", "build-duckdb-db": "ts-node scripts/build_duckdb_test_database", - "ping-db": "ts-node ./test/bin/ping_db.ts" + "ping-db": "ts-node ./test/bin/ping_db.ts", + "describe-cube": "ts-node scripts/describe_cube.ts" }, "devDependencies": { "@babel/plugin-transform-runtime": "^7.23.3", diff --git a/scripts/describe_cube.ts b/scripts/describe_cube.ts new file mode 100644 index 000000000..d038abda5 --- /dev/null +++ b/scripts/describe_cube.ts @@ -0,0 +1,34 @@ +import t from '/Users/ltabb/Downloads/agg_levels.json'; + +const allDims = new Map(); + +for (const a of t) { + for (const dim of a.agg_level.split('.')) { + allDims.set(dim, 'x'); + } +} + +console.log(` + ##! experimental{composite_sources} + source: cube_root is presto_de.table('peu_cube_agg_level:measurementsystems')`); + +for (const cube of t) { + const name = '`cube' + cube.agg_level + '`'; + const levels = cube.agg_level.split('.'); + const except = + '`' + + Array.from(allDims.keys()) + .filter(x => !levels.includes(x)) + .join('`,`') + + '`'; + console.log(` + source: \`cube.${cube.agg_level}\` is cube_root extend { + except: ${except} + where: agg_level = '${cube.agg_level}' + } +`); +} + +console.log(`source: cube_base is compose(`); +console.log('`' + t.map(x => 'cube.' + x.agg_level).join('`,`') + '`'); +console.log(`)`);