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: implement primitive query procedures #833

Merged
merged 16 commits into from
Mar 8, 2025

Conversation

outerlook
Copy link
Contributor

@outerlook outerlook commented Mar 6, 2025

Description

  • this PR contains fixes to all test helpers, trying to unify back to a usable state, although the tests that use them are still commented out.
  • created a new branch on SDK-GO referent to the kwil 0.10 upgrade, otherwise we can't use our SDK as a dependency
  • Moved and relabeled tests from primitive tests to query
  • reimplemented the tests

Related Problem

How Has This Been Tested?

Note: Although tests have been created, they are not working at all. There are 2 bugs (only one confirmed) that we are waiting for fixes from the kwil team. However, it might be more productive to keep going and finalize tests on another PR.

…and management

This commit introduces a series of SQL migration files that define the core infrastructure for stream querying and management, including:

- Enhanced table schemas for taxonomies, primitive events, and metadata
- New actions for stream type detection and authorization
- Comprehensive query actions for primitive and composed streams
- Public routing actions to handle different stream types dynamically
- Placeholder implementations for composed stream queries
- Improved error handling and access control mechanisms

The migration files cover key functionalities such as record insertion, metadata retrieval, read/write permissions, and flexible querying across primitive and composed stream types.
@outerlook outerlook self-assigned this Mar 6, 2025
@outerlook
Copy link
Contributor Author

hey @MicBun, don't know if it's the most appropriate yet, but tried to organize some migration files on this pr

.
├── 000-initial-data.sql
├── 001-common-actions.sql
├── 002-authorization.sql
├── 003-primitive-insertion.sql
├── 004-composed-taxonomy.sql
├── 005-primitive-query.sql
├── 006-composed-query.sql
└── 006-public-query.sql

…ency

Bump trufnetwork/sdk-go to version v0.2.1-0.20250306192322-57cbdf7b5b77 in project dependencies
…ieval actions

This commit improves the database migration files by adding:
- A comprehensive `get_metadata` action with flexible pagination and ordering
- New `is_wallet_allowed_to_write` action for granular write permissions
- Updated `insert_record` action with more precise error handling and permission checks
- Placeholder `insert_taxonomy` action for future implementation
- Minor syntax and parameter improvements across migration files
… and simplified interfaces

This commit refactors the test utilities for streams, focusing on:
- Replacing date-based inputs with event time integers
- Simplifying markdown parsing and data insertion logic
- Updating function signatures to use more precise types
- Removing commented-out legacy code
- Improving type conversion and error handling in test setup functions
This commit updates the primitive stream test suite by:
- Uncommented and re-implemented previously disabled test functions
- Updated test setup to use new SDK and utility functions
- Replaced date-based comparisons with event time integers
- Simplified stream creation and record insertion logic
- Improved type safety and error handling in test procedures
@outerlook outerlook changed the title chore: bump kwil-db depedency to v0.10.0-beta.3 (#797) feat: implement primitive query procedures Mar 6, 2025
outerlook added 10 commits March 7, 2025 17:50
This commit introduces a new SQL migration file with public routing actions that dynamically handle queries for both primitive and composed streams. The migration defines five key public actions:

- `get_record`: Routes record retrieval based on stream type
- `get_last_record`: Finds the last record before a given timestamp
- `get_first_record`: Retrieves the first record after a specified time
- `get_base_value`: Determines the base value for a stream
- `get_index`: Calculates index values for streams

Each action uses `is_primitive_stream()` to dynamically route to the appropriate internal query method, providing a flexible and type-safe approach to stream querying.
…handling and logging

This commit updates the primitive stream query actions in the database migration files with several key improvements:

- Renamed timestamp columns from `ts` to `event_time` for consistency
- Added detailed logging statements to track query execution
- Updated error messages to include more context (data_provider, stream_id)
- Modified query logic to handle edge cases in record retrieval
- Temporarily modified `get_last_record_primitive` to return a test record for debugging
- Standardized parameter naming across query actions (e.g., `$from` instead of `$from_time`)

The changes aim to improve debugging capabilities and provide more informative error messages during stream querying operations.
This commit introduces several improvements to stream test utilities:
- Updated primitive stream test to use a wrapper function for test setup
- Modified procedure calls to swap parameter order for data provider and stream ID
- Converted float types from float32 to float64 for better precision
- Added explicit decimal parsing for primitive stream data insertion
- Simplified type conversions in markdown parsing and data setup functions
…ling

This commit significantly improves the `get_record_primitive` and `get_last_record_primitive` actions by:
- Implementing a more robust query strategy with gap filling
- Using window functions to handle record selection
- Simplifying query logic and reducing unnecessary logging
- Removing test-specific code and placeholder functions
- Enhancing record retrieval with more precise filtering and ordering
This commit enhances the database migration file by:
- Updating and adding composite indexes for streams, taxonomies, primitive events, and metadata tables
- Introducing more targeted indexes to support complex query patterns
- Improving index strategies for time-series data retrieval
- Adding indexes to optimize gap-filling and window function queries
- Enhancing index selection for active (non-disabled) record lookups
… coverage

This commit enhances the primitive stream test suite by:
- Replacing date-based comparisons with event time integers
- Updating test functions to use new stream locator and deployer methods
- Re-enabling previously commented-out test scenarios
- Improving test coverage for record retrieval, index calculations, and data insertion
- Standardizing test setup and validation across different test cases
This commit introduces a new migration utility that:
- Uses Go's embed feature to include SQL seed files
- Provides a method to retrieve absolute paths of embedded seed scripts
- Handles error cases for missing seed files
- Supports dynamic discovery of SQL migration files
This commit enhances the stream query test suite by:
- Creating dedicated query test files for different query behaviors
- Migrating existing primitive stream tests to new query test structure
- Implementing tests for key query behaviors defined in streams_behaviors.md
- Using migrations utility for seed script management
- Standardizing test setup and validation across query test scenarios
- Removing redundant and commented-out test code
This commit updates the Go module dependencies for Kwil-DB to the latest release candidate versions, rolling back from the development snapshot to a more stable RC release.
@outerlook outerlook marked this pull request as ready for review March 8, 2025 16:13
@outerlook outerlook requested a review from MicBun March 8, 2025 16:13
Co-authored-by: Raffael Campos <[email protected]>
@outerlook outerlook merged commit 8311581 into refactor/node-2.0 Mar 8, 2025
3 of 5 checks passed
@outerlook outerlook deleted the feat/primitive-query branch March 8, 2025 16:22
@outerlook outerlook linked an issue Mar 8, 2025 that may be closed by this pull request
Copy link

pr-time-tracker bot commented Mar 10, 2025

@outerlook
⚠️⚠️⚠️
You must submit the time spent on this PR.
⚠️⚠️⚠️

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.

Problem: missing write stream authorization Problem: missing primitive retrieval implementation
2 participants