-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identical measures behave differently: one causes "Unrecognized name" error in generated SQL for BigQuery #8206
Comments
grzaks
added
the
question
The issue is a question. Please use Stack Overflow for questions.
label
Apr 30, 2024
I'm sorry to open this issue again @paveltiunov but I just tested it on v0.35.30 with the same exact schema as above (except Hash of the image: % kubectl get -o json pod cube-api-f9f858f89-w75vw | grep "imageID"
"imageID": "docker.io/cubejs/cube@sha256:a3d4763f4bc1871c1d187f7a2b6ab7c4783b89c4a563c45673f2240656422b61", From inside the container: root@cube-api-f9f858f89-w75vw:/cube# grep version package.json
"version": "0.35.30", Is there any way I can help here?
cube(`poc_orders`, {
public: false,
sql: `
SELECT co.*
FROM cubes.orders co
WHERE ${FILTER_PARAMS.poc_orders.work_date.filter("addTimestamp")}
`,
joins: {
poc_daily_metrics: {
relationship: `many_to_one`,
sql: `
${branch_uid} = ${poc_daily_metrics.branch_uid}
AND DATE(${work_date}) = ${poc_daily_metrics.work_date}
`,
},
},
measures: {
count: {
type: 'count',
},
count2: {
type: 'count',
},
something: {
sql: `${count} * ${poc_daily_metrics.finished_orders_count}`,
type: 'number'
},
measure_working_fine: {
sql: `${something}/${count}`,
type: 'number',
},
measure_causing_error: {
sql: `${something}/${count2}`,
type: 'number',
},
},
dimensions: {
uid: {
sql: `${CUBE}.uid`,
type: `string`,
primaryKey: true,
},
branch_uid: {
sql: `${CUBE}.branchUid`,
type: `string`,
},
work_date: {
sql: `${CUBE}.addTimestamp`,
type: `time`,
},
},
})
cube(`poc_daily_metrics`,
{
public: false,
sql: `
SELECT
DATE(startTimestamp) as workDate,
branchUid,
COUNT(*) as finishedCount
FROM cubes.activities
WHERE (
${FILTER_PARAMS.poc_orders.work_date.filter("startTimestamp")}
)
GROUP BY 1, 2
`,
measures: {
finished_orders_count: {
sql: `${CUBE}.finishedCount`,
type: 'sum',
},
},
dimensions: {
id: {
sql: `${work_date} || ${branch_uid}`,
type: `string`,
primaryKey: true,
},
branch_uid: {
sql: `${CUBE}.branchUid`,
type: `string`,
},
work_date: {
sql: `${CUBE}.workDate`,
type: `time`,
},
}
}
) Part of the console log:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
The following schema is simplified example of an issue I have with my production schema (~15 cubes, BigQuery data source). It consists of just two joined cubes
poc_orders
andpoc_daily_metrics
and some simple measures defined.There is
poc_orders.something
measure that is using related cube measure. If you query this measure everything works as you might expect. Then there arepoc_orders.count
andpoc_orders.count2
measures which are identical.There is
measure_working_fine
which dividespoc_orders.something
bypoc_orders.count
and this one works fine.Then there is
measure_causing_error
which dividespoc_orders.something
bypoc_orders.count2
and here comes the issue: queryingmeasure_causing_error
makes the generated SQL that causesUnrecognized name: poc_orders at [1:79]
error at BigQuery. Unless you query it together withpoc_orders.count2
, then it works fine.How is that possible if
count
andcount2
measures are 100% identical? Why it works only whenpoc_orders.count2
is also part of the query?I pasted related schema file, generated SQL and log below and in this gist
Related Cube.js schema
Related Cube.js generated SQL for measure_working_fine
Related Cube.js generated SQL for measure_causing_error
Diff between the two above generated SQLs
Part of the cube console output
The Cube version is v0.35.24
The text was updated successfully, but these errors were encountered: