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

Adding Apache Pinot Query Runner #5798

Merged
merged 2 commits into from
Oct 7, 2022
Merged

Conversation

xiangfu0
Copy link
Contributor

@xiangfu0 xiangfu0 commented Jul 18, 2022

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • New Query Runner (Data Source)
  • New Alert Destination
  • Other

Description

Adding Apache Pinot query runner.

How is this tested?

  • Unit tests (pytest, jest)
  • E2E Tests (Cypress)
  • Manually
  • N/A

1. Start redash docker-compose

docker-compose up -d && docker-compose run --rm server create_db && docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests"

2. Start Pinot Quickstart

docker run \
    --name pinot-quickstart \
    --network redash_default \
    -p 9000:9000 -d \
    apachepinot/pinot:latest QuickStart \
    -type batch

This docker run create a Pinot cluster with controller at http://pinot-quickstart:9000 and broker athttp://pinot-quickstart:8000

3. Create data source:

image

4. Query Builder

image

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

@xiangfu0 xiangfu0 changed the title Adding Apache Pinot integration Adding Apache Pinot Query Runner Jul 18, 2022
@xiangfu0
Copy link
Contributor Author

Just realized the duplicated effort #5724

@susodapop
Copy link
Contributor

I'm not seeing any movement on #5724 from that contributor. So I'm happy to move forward with this one assuming we can incorporate the feedback from the two previous attempts. The big question was around data type mapping, as I recall.

@xiangfu0 xiangfu0 force-pushed the pinot-integration branch 2 times, most recently from 085ca51 to 45ab4f2 Compare July 19, 2022 08:34
@xiangfu0
Copy link
Contributor Author

Adding more type support:
image

@xiangfu0
Copy link
Contributor Author

Also tested with auth-zk pinot quickstart:

docker run --name pinot-quickstart --network redash_default \
    -p 9000:9000 -p 8000:8000  -d\
    apachepinot/pinot:latest QuickStart \
    -type AUTH-ZK

With Data Source
image

@susodapop
Copy link
Contributor

Please let me know when you feel this is ready for review 👌

@xiangfu0
Copy link
Contributor Author

Please let me know when you feel this is ready for review 👌

Yes, please. Logic wise it's pretty much there.

@xiangfu0
Copy link
Contributor Author

I've tried to capture the feedbacks for type mapping from #5724 and #5446

@xiangfu0
Copy link
Contributor Author

xiangfu0 commented Aug 1, 2022

@susodapop can you start reviewing this PR, thanks!

@susodapop
Copy link
Contributor

Thanks for the ping! I will review it this week.

@xiangfu0
Copy link
Contributor Author

Thanks for the ping! I will review it this week.

Kindly bump up the thread :p

@xiangfu0
Copy link
Contributor Author

Guess I forgot to @susodapop last week :p

Copy link
Contributor

@susodapop susodapop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your patience. This looks great overall! Please see my comments and let me know if you have questions.

requirements_all_ds.txt Outdated Show resolved Hide resolved
redash/query_runner/pinot.py Outdated Show resolved Hide resolved
redash/query_runner/pinot.py Outdated Show resolved Hide resolved
redash/query_runner/pinot.py Outdated Show resolved Hide resolved
Comment on lines +98 to +110
for schema_name in self.get_schema_names():
for table_name in self.get_table_names():
schema_table_name = "{}.{}".format(schema_name, table_name)
if table_name not in schema:
schema[schema_table_name] = {"name": schema_table_name, "columns": []}
table_schema =self.get_pinot_table_schema(table_name)

for column in table_schema.get("dimensionFieldSpecs", []) + table_schema.get(
"metricFieldSpecs", []) + table_schema.get("dateTimeFieldSpecs", []):
c = {
"name": column["name"],
"type": PINOT_TYPES_MAPPING[column["dataType"]],
}
schema[schema_table_name]["columns"].append(c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: is there a way to pull the entire schema in one roundtrip to Pinot? This approach of looping through schemas -> tables -> columns will work but scales linearly as a schema grows. This isn't a blocker to merge but perhaps a way to incrementally improve in the future.

Looking at the Pinot docs it seems we could pull the entire schema in one roundtrip: https://docs.pinot.apache.org/users/tutorials/schema-evolution#get-the-existing-schema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinot doesn't support fetch all schemas at once, so this is the only way.

image

return list(schema.values())

def get_schema_names(self):
return ["default"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Pinot support schema names other than default? If so we should make this configurable or fetch them directly from the database.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now there is no concept of schema, so just use default for now.
Later we may consider adding tenant names as part of the schemas.

redash/query_runner/pinot.py Outdated Show resolved Hide resolved
redash/query_runner/pinot.py Outdated Show resolved Hide resolved
redash/query_runner/pinot.py Outdated Show resolved Hide resolved
@susodapop
Copy link
Contributor

Guess I forgot to @susodapop last week :p

I appreciate you pinging me so reliably. I've been hard at work on a couple other open source projects for the past month. But I swear I haven't forgotten about you :)

@xiangfu0 xiangfu0 force-pushed the pinot-integration branch 2 times, most recently from e3058c9 to 03ea39c Compare September 8, 2022 03:10
@xiangfu0 xiangfu0 requested a review from susodapop September 8, 2022 07:54
@xiangfu0
Copy link
Contributor Author

xiangfu0 commented Sep 8, 2022

Guess I forgot to @susodapop last week :p

I appreciate you pinging me so reliably. I've been hard at work on a couple other open source projects for the past month. But I swear I haven't forgotten about you :)

Thanks for your comments!

Seems the CI cannot pass due to some visual change, can you help check what's going on?

@xiangfu0
Copy link
Contributor Author

@susodapop another round :p

@xiangfu0 xiangfu0 closed this Sep 24, 2022
@xiangfu0 xiangfu0 reopened this Sep 24, 2022
@xiangfu0
Copy link
Contributor Author

Seems like the CI passed!
@susodapop can you go through this again ?

@xiangfu0
Copy link
Contributor Author

@susodapop ping :p

@xiangfu0
Copy link
Contributor Author

kindly Friday ping 🔢
@susodapop

@susodapop
Copy link
Contributor

Thank you for the pings :) I have been out sick this week. Will review ASAP.

@xiangfu0
Copy link
Contributor Author

Thank you for the pings :) I have been out sick this week. Will review ASAP.

Oh, hope you get well soon and take your time!

@arikfr arikfr merged commit a863c8c into getredash:master Oct 7, 2022
@arikfr
Copy link
Member

arikfr commented Oct 7, 2022

Merged. Thank you for your patience with this, @xiangfu0 !

@xiangfu0 xiangfu0 deleted the pinot-integration branch October 7, 2022 18:00
@xiangfu0
Copy link
Contributor Author

xiangfu0 commented Oct 7, 2022

Many thanks @arikfr and @susodapop !! Great team work!

blarghmatey pushed a commit to mitodl/redash that referenced this pull request Oct 27, 2022
* Adding Apache Pinot integration

* address comments
AkaashK pushed a commit to tharzeez/redash that referenced this pull request Jul 18, 2023
* Adding Apache Pinot integration

* address comments
harveyrendell pushed a commit to pushpay/redash that referenced this pull request Jan 8, 2025
* Adding Apache Pinot integration

* address comments
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.

3 participants