-
Notifications
You must be signed in to change notification settings - Fork 12
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
SQL conversion of relative forms #3419
Conversation
This reverts commit 55c33eb.
…s/README.md Co-authored-by: Torben Meyer <torben.meyer@bakdata.com>
…s/README.md Co-authored-by: Torben Meyer <torben.meyer@bakdata.com>
…ect/HanaSqlFunctionProvider.java Co-authored-by: Torben Meyer <torben.meyer@bakdata.com>
…sion' into sql/feature/absolute-form-conversion
…s/README.md Co-authored-by: awildturtok <1553491+awildturtok@users.noreply.github.com>
…conversion # Conflicts: # backend/src/main/java/com/bakdata/conquery/sql/conversion/dialect/HanaSqlFunctionProvider.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/dialect/PostgreSqlFunctionProvider.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/dialect/SqlDialect.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/FormCteStep.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/HanaStratificationFunctions.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/README.md # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/StratificationFunctions.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/StratificationTableFactory.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/query/AbsoluteFormQueryConverter.java
// end date of validity dates is exclusive, but we need the inclusive one | ||
case LATEST -> functionProvider.addDays(DSL.max(validityDate.getEnd()), DSL.val(-1)); | ||
case RANDOM -> { | ||
// TODO seed required? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich glaube wir hatten darüber mal gesprochen, dass es einen Seed dafür bei euch gibt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Genau, der ist als Konstante in ConqueryConstants.RANDOM_SEED festgelegt.
Es war nur wichtig, dass der Seed konstant war zur Reproduzierbarkeit von eventuellen Fehlern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also das Problem ist, dass nach meinem Kenntnisstand für HANA keine Möglichkeit existiert einen Seed zu setzen. Für Postgres schon.
protected Field<Date> jumpToNextQuarterStart(Field<Date> date) { | ||
Field<Timestamp> yearStart = dateTruncate(DSL.val("year"), date); | ||
Field<Date> quarterEndInclusive = date.minus(1); | ||
Field<Integer> quarter = functionProvider.extract(DatePart.QUARTER, quarterEndInclusive); | ||
return addQuarters(yearStart, quarter, Offset.NONE); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kann es sein, dass die Funktion mit einem Datum wie z.B. 01.01.2024 das falsche Ergebnis rausgibt.
Statt 01.10.2023, kommt dann 01.10.2024 heraus.
case EARLIEST -> DSL.min(lower(validityDate)); | ||
// upper returns the exclusive end date, we want to inclusive one, so we add -1 day | ||
case LATEST -> functionProvider.addDays(DSL.max(upper(validityDate)), DSL.val(-1)); | ||
case RANDOM -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hier bitte auch einen konstanten Seed nutzen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man kann in SQL den seed nicht so setzen, wie wir das machen, das müsste dann als CTE in jeder Query passieren
...src/main/java/com/bakdata/conquery/sql/conversion/forms/PostgresStratificationFunctions.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
protected Field<Date> jumpToNextQuarterStart(Field<Date> date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quartal 4 landet im nächsten Jahr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ist in dem Fall beabsichtigt.
Field<Date> yearStart = jumpToYearStart(dateRange.getEnd()); | ||
Field<Date> inclusiveEnd = functionProvider.addDays(dateRange.getEnd(), DSL.val(-1)); | ||
Field<Integer> quartersInMonths = getMonthsInQuarters(inclusiveEnd, Offset.NONE); | ||
return jumpToNextQuarterStart(dateRange.getEnd()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minus 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍 Danke dir.
} | ||
|
||
@Override | ||
public Field<Date> quarterEnd(ColumnDateRange dateRange) { | ||
Field<Timestamp> yearStart = dateTruncate(DSL.val("year"), upper(dateRange)); | ||
Field<Date> quarterEndInclusive = upper(dateRange).minus(1); | ||
return jumpToNextQuarterStart(upper(dateRange)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
links hattest du auch noch minus 1, kannst du bitte einen kommentar dran machen, wrum du das nicht brauchst?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich brauche sie, hatte es allerdings an der falschen Stelle in der jumpToNextQuarterStart() Methode.
case EARLIEST -> DSL.min(lower(validityDate)); | ||
// upper returns the exclusive end date, we want to inclusive one, so we add -1 day | ||
case LATEST -> functionProvider.addDays(DSL.max(upper(validityDate)), DSL.val(-1)); | ||
case RANDOM -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man kann in SQL den seed nicht so setzen, wie wir das machen, das müsste dann als CTE in jeder Query passieren
backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/RelativeStratification.java
Outdated
Show resolved
Hide resolved
…s/RelativeStratification.java Co-authored-by: awildturtok <1553491+awildturtok@users.noreply.github.com>
…ure/relative-form-conversion
…s/PostgresStratificationFunctions.java Co-authored-by: MT <12283268+thoniTUB@users.noreply.github.com>
This reverts commit 37d441c6efce4e423b09e694af19b2eca45029ac.
…ersion # Conflicts: # backend/src/main/java/com/bakdata/conquery/sql/conversion/dialect/SqlDialect.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/FormCteStep.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/HanaStratificationFunctions.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/PostgresStratificationFunctions.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/README.md # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/StratificationFunctions.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/forms/StratificationTableFactory.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/query/AbsoluteFormQueryConverter.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/query/EntityDateQueryConverter.java # backend/src/main/java/com/bakdata/conquery/sql/conversion/query/FormConversionHelper.java
@thoniTUB @awildturtok Vielen dank nochmal für die Hinweise zu den Edge-Cases, da gab es noch einige Fehler. Ich habe dahingehend auch nochmal die Testcases angepasst. Da ist jetzt auch der Edge-Case mit 31.12./01.01. mit dabei. |
No description provided.