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

feat: Add query builder interface #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hzxa21
Copy link
Contributor

@hzxa21 hzxa21 commented Jan 25, 2025

Usage is shown in README.md and demo.py

  • Leverage pypika to support query builder like interfaces
  • Add UTs
  • Clean up some codes
# Batch query
demo.groupby(demo.symbol)
        .select(demo.symbol, Sum(demo.volume))
        .orderby(Sum(demo.volume), order=Order.desc)
        .show(2)

# Streaming query
streaming = (
    rw.query()
    .from_(Tumble(demo, demo.timestamp, Interval(seconds=10)))
    .groupby("window_start", "window_end", demo.symbol)
    .select(
        "window_start",
        "window_end",
        demo.symbol,
        Round(Avg(demo.close)).as_("avg_price"),
    )
    .streaming("tick_analytics")
)
streaming.on_change(
    handler=DemoHandler.on_tick_analytics_changes,
    persist_progress=True,
    output_format=OutputFormat.DATAFRAME,
    max_batch_size=1,
)

Copy link
Contributor

@cloudcarver cloudcarver left a comment

Choose a reason for hiding this comment

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

LGTM!

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