|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a multi-module Maven project for the Flink SQL Runner - a tool and library ecosystem for running Apache Flink SQL applications. The project is structured as a parent POM with multiple modules providing different functionality. |
| 8 | + |
| 9 | +## Module Structure |
| 10 | + |
| 11 | +- `flink-sql-runner/` - Main CLI application and Docker image |
| 12 | +- `connectors/` - Custom Flink connectors (kafka-safe, postgresql) |
| 13 | +- `formats/` - Custom data formats (flexible-csv, flexible-json) |
| 14 | +- `types/` - Custom data types (json-type, vector-type) |
| 15 | +- `stdlib/` - Standard library modules with system functions (json, math, text, vector, openai) |
| 16 | +- `testing/` - Testing utilities and sample UDF projects |
| 17 | + |
| 18 | +## Common Commands |
| 19 | + |
| 20 | +### Building and Testing |
| 21 | +```bash |
| 22 | +# Full build with all checks |
| 23 | +mvn clean install -Pci,flink-1.19 |
| 24 | + |
| 25 | +# Fast build (skips tests, formatting, license checks) |
| 26 | +mvn clean install -Pfast |
| 27 | + |
| 28 | +# Run tests only |
| 29 | +mvn test |
| 30 | + |
| 31 | +# Run integration tests |
| 32 | +mvn verify |
| 33 | + |
| 34 | +# Code formatting check |
| 35 | +mvn spotless:check |
| 36 | + |
| 37 | +# Apply code formatting |
| 38 | +mvn spotless:apply |
| 39 | + |
| 40 | +# License header check |
| 41 | +mvn license:check |
| 42 | + |
| 43 | +# Apply license headers |
| 44 | +mvn license:format |
| 45 | +``` |
| 46 | + |
| 47 | +### Running the Application |
| 48 | +```bash |
| 49 | +# Run SQL file |
| 50 | +java -jar flink-sql-runner/target/flink-sql-runner.jar --sqlfile script.sql |
| 51 | + |
| 52 | +# Run compiled plan |
| 53 | +java -jar flink-sql-runner/target/flink-sql-runner.jar --planfile plan.json |
| 54 | + |
| 55 | +# With custom configuration |
| 56 | +java -jar flink-sql-runner/target/flink-sql-runner.jar --sqlfile script.sql --config-dir config/ |
| 57 | + |
| 58 | +# With UDF path |
| 59 | +java -jar flink-sql-runner/target/flink-sql-runner.jar --sqlfile script.sql --udfpath /path/to/udfs |
| 60 | +``` |
| 61 | + |
| 62 | +## Technology Stack |
| 63 | + |
| 64 | +- **Java 11** - Base language version |
| 65 | +- **Apache Flink 1.19.2** - Stream processing framework (configurable via profiles) |
| 66 | +- **Maven** - Build system |
| 67 | +- **Lombok** - Code generation |
| 68 | +- **PicoCLI** - Command line interface |
| 69 | +- **JUnit 5** - Testing framework |
| 70 | +- **Testcontainers** - Integration testing |
| 71 | +- **Docker** - Containerization |
| 72 | + |
| 73 | +## Development Notes |
| 74 | + |
| 75 | +### Code Style |
| 76 | +- Uses Google Java Format for code formatting |
| 77 | +- Enforced via Spotless Maven plugin |
| 78 | +- License headers are automatically managed |
| 79 | +- Separate formatting rules for Flink-specific code (AOSP style) |
| 80 | + |
| 81 | +### Testing |
| 82 | +- Unit tests: `mvn test` |
| 83 | +- Integration tests: `mvn verify` (includes failsafe plugin) |
| 84 | +- Test coverage enforced at 70% minimum via JaCoCo |
| 85 | + |
| 86 | +### Flink Version Support |
| 87 | +Multiple Flink versions supported via Maven profiles: |
| 88 | +- `flink-1.19` (default) |
| 89 | +- `flink-1.20` |
| 90 | +- `flink-2.0` |
| 91 | + |
| 92 | +### Architecture |
| 93 | +The main application (`CliRunner`) processes command-line arguments and delegates to `BaseRunner` which: |
| 94 | +1. Initializes Flink configuration |
| 95 | +2. Resolves environment variables in SQL/JSON files |
| 96 | +3. Creates `SqlExecutor` to run SQL scripts or compiled plans |
| 97 | +4. Handles UDF loading and system function registration |
| 98 | + |
| 99 | +### Key Classes |
| 100 | +- `CliRunner` - Main entry point and CLI argument processing |
| 101 | +- `BaseRunner` - Core execution logic and configuration |
| 102 | +- `SqlExecutor` - Flink SQL script and plan execution |
| 103 | +- `EnvVarResolver` - Environment variable substitution in configs |
| 104 | + |
| 105 | +### Adding New Modules |
| 106 | +New modules should: |
| 107 | +1. Follow the existing directory structure |
| 108 | +2. Include proper Maven coordinates under `com.datasqrl.flinkrunner` |
| 109 | +3. Add to parent POM modules section |
| 110 | +4. Include common dependencies from parent (Lombok, JUnit, etc.) |
0 commit comments