Skip to content
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

[WAIT] fix: Issue with missing headers when using Doris analytics database #19791

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

luciano-fiandesio
Copy link
Contributor

@luciano-fiandesio luciano-fiandesio commented Jan 28, 2025

Summary

This PR resolves an issue with non-aggregated analytics SQL queries in Doris/Clickhouse, specifically concerning their inability to process Postgis-related columns like latitude and longitude.

Changes

  • Introduced the concept of a "virtual grid header" to address the mismatch.
    • A virtual GridHeader serves as a placeholder without corresponding to any column in the SQL result set.
    • It ensures the preservation of the original GridHeaders by providing default (empty) values in the grid when no underlying data is available.

// Increment the offset for row context (when applicable)
if (params.isRowContext()) {
addValueOriginInfo(grid, rowSet, header.getName());
columnOffset += getRowSetOriginItems(rowSet, header.getName());

Check failure

Code scanning / CodeQL

Implicit narrowing conversion in compound assignment High

Implicit cast of source type long to narrower destination type
int
.

Copilot Autofix AI 15 days ago

To fix the problem, we need to ensure that the type of columnOffset is at least as wide as the type returned by getRowSetOriginItems. The best way to fix this issue without changing existing functionality is to change the type of columnOffset from int to long. This will prevent any implicit narrowing conversion and ensure that the addition operation is safe.

Suggested changeset 1
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEnrollmentAnalyticsManager.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEnrollmentAnalyticsManager.java b/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEnrollmentAnalyticsManager.java
--- a/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEnrollmentAnalyticsManager.java
+++ b/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEnrollmentAnalyticsManager.java
@@ -221,3 +221,3 @@
       // describing the repeating of repeatable stage.
-      int columnOffset = 0;
+      long columnOffset = 0;
       // Start index for SqlRowSet columns. Starts at 1 (NOT 0, per ResultSet conventions).
EOF
@@ -221,3 +221,3 @@
// describing the repeating of repeatable stage.
int columnOffset = 0;
long columnOffset = 0;
// Start index for SqlRowSet columns. Starts at 1 (NOT 0, per ResultSet conventions).
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@larshelge
Copy link
Member

I am wondering if it would be better to handle this client side, and have the client inspect the headers and show/hide the long/lat fields based on the presence in the headers.

@larshelge larshelge changed the title Fix issue with missing headers when using Doris analytics database [WAIT] fix: Issue with missing headers when using Doris analytics database Jan 29, 2025
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants