Commit Graph

11982 Commits

Author SHA1 Message Date
chrislu
fa620f0223 upgrade to raft v1.1.4 resolving race in leader 2025-09-04 23:58:04 -07:00
chrislu
2d582f9cb6 Update SQL_FEATURE_PLAN.md 2025-09-04 23:19:07 -07:00
chrislu
ed57d08909 fix build docker 2025-09-04 23:14:47 -07:00
chrislu
43f8332297 normal if no partitions found 2025-09-04 23:14:36 -07:00
chrislu
f1008b554e improve docker build 2025-09-04 21:23:25 -07:00
chrislu
bdf43f53e9 comment 2025-09-04 21:10:10 -07:00
chrislu
93867ca04b Update mocks_test.go 2025-09-04 21:00:50 -07:00
chrislu
32dc65167f fix comments 2025-09-04 19:44:12 -07:00
chrislu
92a1ab25f4 address comments 2025-09-04 18:41:46 -07:00
chrislu
53d9a81791 fix "use db" 2025-09-04 18:34:05 -07:00
chrislu
04e83281f2 Update SQL_FEATURE_PLAN.md 2025-09-04 18:32:16 -07:00
chrislu
3cbe20e4e8 fix tests 2025-09-04 18:30:46 -07:00
chrislu
9f4d4e4559 using consts; avoid test data in production binary 2025-09-04 18:15:14 -07:00
chrislu
9b1919a8eb int range 2025-09-04 16:40:44 -07:00
chrislu
279abda3b7 support string concatenation || 2025-09-04 16:38:08 -07:00
chrislu
e528629944 avoid closing closed channel 2025-09-04 10:03:33 -07:00
Chris Lu
920becfa5f Update weed/query/engine/hybrid_message_scanner.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-09-04 10:02:32 -07:00
chrislu
d572443c79 ensure int conversion correctness 2025-09-04 09:54:24 -07:00
chrislu
02d36637de limit with offset 2025-09-04 09:13:54 -07:00
chrislu
164158b2a1 Update SQL_FEATURE_PLAN.md 2025-09-04 09:13:46 -07:00
chrislu
20f61388bf support limit with offset 2025-09-04 08:44:29 -07:00
chrislu
e030913d9f clean up 2025-09-04 08:44:29 -07:00
Chris Lu
eec9558925 Update postgres-examples/README.md
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-09-04 08:13:35 -07:00
chrislu
2e4ba5b2fc redirect GetUnflushedMessages to brokers hosting the topic partition 2025-09-04 08:10:19 -07:00
chrislu
19a3da757f Update README.md 2025-09-04 08:08:40 -07:00
chrislu
31d5960f00 int overflow 2025-09-04 08:08:36 -07:00
chrislu
cd928f9f38 heap sort the data sources 2025-09-04 08:08:23 -07:00
chrislu
6fcc573709 fix: Improve test stability for date/time functions
**Problem:**
- CURRENT_TIMESTAMP test had timing race condition that could cause flaky failures
- CURRENT_DATE test could fail if run exactly at midnight boundary
- Tests were too strict about timing precision without accounting for system variations

**Root Cause:**
- Test captured before/after timestamps and expected function result to be exactly between them
- No tolerance for clock precision differences, NTP adjustments, or system timing variations
- Date boundary race condition around midnight transitions

**Solution:**
 **CURRENT_TIMESTAMP test**: Added 100ms tolerance buffer to account for:
  - Clock precision differences between time.Now() calls
  - System timing variations and NTP corrections
  - Microsecond vs nanosecond precision differences

 **CURRENT_DATE test**: Enhanced to handle midnight boundary crossings:
  - Captures date before and after function call
  - Accepts either date value in case of midnight transition
  - Prevents false failures during overnight test runs

**Testing:**
- Verified with repeated test runs (5x iterations) - all pass consistently
- Full test suite passes - no regressions introduced
- Tests are now robust against timing edge cases

**Impact:**
🚀 **Eliminated flaky test failures** while maintaining function correctness validation
🔧 **Production-ready testing** that works across different system environments
 **CI/CD reliability** - tests won't fail due to timing variations
2025-09-04 07:47:17 -07:00
chrislu
2b35cca9bd refactor: Split sql_functions.go into smaller, focused files
**File Structure Before:**
- sql_functions.go (850+ lines)
- sql_functions_test.go (1,205+ lines)

**File Structure After:**
- function_helpers.go (105 lines) - shared utility functions
- arithmetic_functions.go (205 lines) - arithmetic operators & math functions
- datetime_functions.go (170 lines) - date/time functions & constants
- string_functions.go (335 lines) - string manipulation functions
- arithmetic_functions_test.go (560 lines) - tests for arithmetic & math
- datetime_functions_test.go (370 lines) - tests for date/time functions
- string_functions_test.go (270 lines) - tests for string functions

**Benefits:**
 Better organization by functional domain
 Easier to find and maintain specific function types
 Smaller, more manageable file sizes
 Clear separation of concerns
 Improved code readability and navigation
 All tests passing - no functionality lost

**Total:** 7 focused files (1,455 lines) vs 2 monolithic files (2,055+ lines)

This refactoring improves maintainability while preserving all functionality.
2025-09-04 06:56:06 -07:00
chrislu
179a7b446e feat: Add comprehensive string functions with extensive tests
Implemented String Functions:
- LENGTH: Get string length (supports all value types)
- UPPER/LOWER: Case conversion
- TRIM/LTRIM/RTRIM: Whitespace removal (space, tab, newline, carriage return)
- SUBSTRING: Extract substring with optional length (SQL 1-based indexing)
- CONCAT: Concatenate multiple values (supports mixed types, skips nulls)
- REPLACE: Replace all occurrences of substring
- POSITION: Find substring position (1-based, 0 if not found)
- LEFT/RIGHT: Extract leftmost/rightmost characters
- REVERSE: Reverse string with proper Unicode support

Key Features:
- Robust type conversion (string, int, float, bool, bytes)
- Unicode-safe operations (proper rune handling in REVERSE)
- SQL-compatible indexing (1-based for SUBSTRING, POSITION)
- Comprehensive error handling with descriptive messages
- Mixed-type support (e.g., CONCAT number with string)

Helper Functions:
- valueToString: Convert any schema_pb.Value to string
- valueToInt64: Convert numeric values to int64

Comprehensive test suite with 25+ test cases covering:
- All string functions with typical use cases
- Type conversion scenarios (numbers, booleans)
- Edge cases (empty strings, null values, Unicode)
- Error conditions and boundary testing

All tests passing 
2025-09-04 00:21:17 -07:00
chrislu
25b07fda6c feat: Add DATE_TRUNC function with comprehensive tests
- Implement comprehensive DATE_TRUNC function supporting:
  - Time precisions: microsecond, millisecond, second, minute, hour
  - Date precisions: day, week, month, quarter, year, decade, century, millennium
  - Support both singular and plural forms (e.g., 'minute' and 'minutes')
- Enhanced date/time parsing with proper timezone handling:
  - Assume local timezone for non-timezone string formats
  - Support UTC formats with explicit timezone indicators
  - Consistent behavior between parsing and truncation
- Comprehensive test suite with 11 test cases covering:
  - All supported precisions from microsecond to year
  - Multiple input types (TimestampValue, string dates)
  - Edge cases (null values, invalid precisions)
  - Timezone consistency validation

All tests passing 
2025-09-04 00:18:31 -07:00
chrislu
ac69d6e5c7 feat: Add date/time functions CURRENT_DATE, CURRENT_TIMESTAMP, EXTRACT with comprehensive tests
- Implement CURRENT_DATE returning YYYY-MM-DD format
- Add CURRENT_TIMESTAMP returning TimestampValue with microseconds
- Add CURRENT_TIME returning HH:MM:SS format
- Add NOW() as alias for CURRENT_TIMESTAMP
- Implement comprehensive EXTRACT function supporting:
  - YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
  - QUARTER, WEEK, DOY (day of year), DOW (day of week)
  - EPOCH (Unix timestamp)
- Support multiple input formats:
  - TimestampValue (microseconds)
  - String dates (multiple formats)
  - Unix timestamps (int64 seconds)
- Comprehensive test suite with 15+ test cases covering:
  - All date/time constants
  - Extract from different value types
  - Error handling for invalid inputs
  - Timezone handling

All tests passing 
2025-09-04 00:16:22 -07:00
chrislu
cc3ac76304 feat: Add mathematical functions ROUND, CEIL, FLOOR, ABS with comprehensive tests
- Implement ROUND with optional precision parameter
- Add CEIL function for rounding up to nearest integer
- Add FLOOR function for rounding down to nearest integer
- Add ABS function for absolute values with type preservation
- Support all numeric types (int32, int64, float32, double)
- Comprehensive test suite with 20+ test cases covering:
  - Positive/negative numbers
  - Integer/float type preservation
  - Precision handling for ROUND
  - Null value error handling
  - Edge cases (zero, large numbers)

All tests passing 
2025-09-04 00:14:51 -07:00
chrislu
32bd48ffb8 feat: Add basic arithmetic operators (+, -, *, /, %) with comprehensive tests
- Implement EvaluateArithmeticExpression with support for all basic operators
- Handle type conversions between int, float, string, and boolean
- Add proper error handling for division/modulo by zero
- Include 14 comprehensive test cases covering all edge cases
- Support mixed type arithmetic (int + float, string numbers, etc.)

All tests passing 
2025-09-04 00:13:51 -07:00
chrislu
bdf3f7caa9 fix 2025-09-04 00:07:06 -07:00
chrislu
a17062218c fix 2025-09-03 22:57:47 -07:00
chrislu
6dcade043b code reuse 2025-09-03 21:55:32 -07:00
Chris Lu
623a278a0f Update SQL_FEATURE_PLAN.md
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-09-03 21:55:12 -07:00
Chris Lu
5adea57224 Update weed/util/log_buffer/log_buffer.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-09-03 21:54:51 -07:00
chrislu
d192536376 fix 2025-09-03 21:44:27 -07:00
chrislu
eb03d05c97 fmt 2025-09-03 17:58:11 -07:00
chrislu
bdce5439d8 fixes 2025-09-03 17:57:06 -07:00
chrislu
1db1206827 fix splitting multiple SQLs 2025-09-03 17:47:24 -07:00
chrislu
ea758d0d9f remove sleep 2025-09-03 17:43:54 -07:00
chrislu
69e6902072 handling errors 2025-09-03 17:42:30 -07:00
chrislu
4060ea34a9 Update SQL_FEATURE_PLAN.md 2025-09-03 17:42:15 -07:00
chrislu
191bad0a21 timeout client connections 2025-09-03 15:49:27 -07:00
chrislu
323193cf8c no more mysql 2025-09-03 15:34:39 -07:00
chrislu
bec567598f fix tests, avoid panic 2025-09-03 10:27:50 -07:00
chrislu
48a9bee3b8 fix describe issue 2025-09-03 10:16:19 -07:00