Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy Documentation

on:
push:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Doxygen
run: |
sudo apt-get update
sudo apt-get install -y doxygen graphviz

- name: Generate Documentation
run: doxygen Doxyfile

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/html'

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)
project(databricks_sdk
VERSION 0.1.0
VERSION 0.2.0
DESCRIPTION "Databricks C++ SDK"
LANGUAGES CXX)

Expand Down Expand Up @@ -86,27 +86,33 @@ endif()

# External libraries
find_package(spdlog CONFIG REQUIRED)
find_package(CURL REQUIRED)
find_package(nlohmann_json REQUIRED)

# Library sources
set(SOURCES
src/client.cpp
src/config.cpp
src/core/client.cpp
src/core/config.cpp
src/jobs/jobs.cpp
src/connection_pool.cpp
src/internal/pool_manager.cpp
src/internal/logger.cpp
src/internal/http_client.cpp
)

set(HEADERS
include/databricks/client.h
include/databricks/config.h
include/databricks/core/client.h
include/databricks/core/config.h
include/databricks/connection_pool.h
include/databricks/version.h
include/databricks/jobs/jobs.h
)

# Internal headers (not installed)
set(INTERNAL_HEADERS
src/internal/pool_manager.h
src/internal/logger.h
src/internal/http_client.h
)

# Create library target
Expand All @@ -122,16 +128,17 @@ target_include_directories(databricks_sdk
)

# Link ODBC libraries
target_link_libraries(databricks_sdk PRIVATE
target_link_libraries(databricks_sdk PRIVATE
${ODBC_LIBRARIES}
spdlog::spdlog
CURL::libcurl
nlohmann_json::nlohmann_json
)

# Set library properties
set_target_properties(databricks_sdk PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER "${HEADERS}"
)

# Set RPATH for finding ODBC libraries at runtime (Unix/Linux/macOS only)
Expand Down Expand Up @@ -170,7 +177,12 @@ install(TARGETS databricks_sdk
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/databricks
)

# Install headers with directory structure preserved
install(DIRECTORY include/databricks/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/databricks
FILES_MATCHING PATTERN "*.h"
)

install(EXPORT databricks_sdk-targets
Expand Down
1 change: 1 addition & 0 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GENERATE_HTML = YES
GENERATE_LATEX = NO
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_EXTRA_FILES = docs/html/.nojekyll

# Documentation extraction
EXTRACT_ALL = YES
Expand Down
124 changes: 110 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

[![Latest Release](https://img.shields.io/github/v/release/calvinjmin/databricks-sdk-cpp?display_name=tag&sort=semver)](https://github.com/calvinjmin/databricks-sdk-cpp/releases/latest)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://calvinjmin.github.io/databricks-sdk-cpp/)

A C++ SDK for Databricks, providing an interface for interacting with Databricks services.

**Latest Release**: [v0.1.0](https://github.com/calvinjmin/databricks-sdk-cpp/releases/tag/v0.1.0) | **Author**: Calvin Min (calvinjmin@gmail.com)
**Latest Release**: [v0.1.0](https://github.com/calvinjmin/databricks-sdk-cpp/releases/tag/v0.1.0)

**Author**: Calvin Min (calvinjmin@gmail.com)

---

## Table of Contents

Expand Down Expand Up @@ -112,7 +117,7 @@ include(FetchContent)
FetchContent_Declare(
databricks_sdk
GIT_REPOSITORY https://github.com/calvinjmin/databricks-sdk-cpp.git
GIT_TAG v0.1.0 # or use 'main' for latest
GIT_TAG main # latest tag or declare a specific version like 0.1.0
)

FetchContent_MakeAvailable(databricks_sdk)
Expand Down Expand Up @@ -494,6 +499,9 @@ After building with `BUILD_EXAMPLES=ON`, examples are organized by feature:
```bash
# Simple SQL query
./examples/simple_query

# Jobs API - list jobs, get details, trigger runs
./examples/jobs_example
```

### Connection Pooling Examples
Expand Down Expand Up @@ -571,6 +579,58 @@ Async operations reduce perceived latency by performing work in the background:

## Advanced Usage

### Jobs API

Interact with Databricks Jobs to automate and orchestrate data workflows:

```cpp
#include <databricks/jobs.h>
#include <databricks/config.h>

int main() {
// Load auth configuration
databricks::AuthConfig auth = databricks::AuthConfig::from_environment();

// Create Jobs API client
databricks::Jobs jobs(auth);

// List all jobs
auto job_list = jobs.list_jobs(25, 0);
for (const auto& job : job_list) {
std::cout << "Job: " << job.name
<< " (ID: " << job.job_id << ")" << std::endl;
}

// Get specific job details
auto job = jobs.get_job(123456789);
std::cout << "Created by: " << job.creator_user_name << std::endl;

// Trigger a job run with parameters
std::map<std::string, std::string> params;
params["date"] = "2024-01-01";
params["environment"] = "production";

uint64_t run_id = jobs.run_now(123456789, params);
std::cout << "Started run: " << run_id << std::endl;

return 0;
}
```

**Key Features:**
- **List jobs**: Paginated listing with limit/offset support
- **Get job details**: Retrieve full job configuration and metadata
- **Trigger runs**: Start jobs with optional notebook parameters
- **Type-safe IDs**: Uses `uint64_t` to correctly handle large job IDs
- **JSON parsing**: Built on `nlohmann/json` for reliable parsing

**API Compatibility:**
- Uses Jobs API 2.2 for full feature support including pagination
- Timestamps returned as Unix milliseconds (`uint64_t`)
- Automatic error handling with descriptive messages

For a complete example, see `examples/basic/jobs_example.cpp`.

### Direct ConnectionPool Management

For advanced users who need fine-grained control over connection pools:
Expand Down Expand Up @@ -605,24 +665,60 @@ std::cout << "Available: " << stats.available_connections << std::endl;

## Documentation

Generate API documentation from code comments:
The SDK includes comprehensive API documentation generated from code comments using Doxygen.

### 📚 View Online Documentation

**Live Documentation**: [https://calvinjmin.github.io/databricks-sdk-cpp/](https://calvinjmin.github.io/databricks-sdk-cpp/)

The documentation is automatically built and published via GitHub Actions whenever changes are pushed to the `main` branch.

### Generate Documentation Locally

```bash
# Install Doxygen (macOS)
brew install doxygen
# Install Doxygen
brew install doxygen # macOS
# or: sudo apt-get install doxygen # Linux

# Generate documentation
make docs
# Generate docs (creates docs/html/)
doxygen Doxyfile

# Open documentation in browser
open docs/html/index.html
# View in browser
open docs/html/index.html # macOS
# or: xdg-open docs/html/index.html # Linux
```

### Documentation Features

The generated documentation includes:

- **Complete API Reference**: All public classes, methods, and structs with detailed descriptions
- **README Integration**: Full README displayed as the main landing page
- **Code Examples**: Inline examples from header comments
- **Jobs API Documentation**: Full reference for `databricks::Jobs`, `Job`, and `JobRun` types
- **SQL Client Documentation**: Complete `databricks::Client` API reference
- **Connection Pooling**: `databricks::ConnectionPool` and configuration types
- **Source Browser**: Browse source code with syntax highlighting
- **Search Functionality**: Quick search across all documentation
- **Cross-references**: Navigate between related classes and methods

### Quick Links (After Generation)

- **Main Page**: `docs/html/index.html` - README and getting started
- **Classes**: `docs/html/annotated.html` - All classes and structs
- **Jobs API**: `docs/html/classdatabricks_1_1_jobs.html` - Jobs API reference
- **Client API**: `docs/html/classdatabricks_1_1_client.html` - SQL client reference
- **Files**: `docs/html/files.html` - Browse by file

### Example: Viewing Jobs API Docs

```bash
# Generate and open Jobs API documentation
doxygen Doxyfile
open docs/html/classdatabricks_1_1_jobs.html
```

The documentation includes:
- API reference for all classes and methods
- Code examples from comments
- Class diagrams and inheritance trees
- Search functionality
The documentation is automatically generated from the inline comments in header files, ensuring it stays synchronized with the code.

## License

Expand Down
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ target_link_libraries(secure_query PRIVATE databricks_sdk)
add_executable(modular_config_example basic/modular_config_example.cpp)
target_link_libraries(modular_config_example PRIVATE databricks_sdk)

add_executable(jobs_example basic/jobs_example.cpp)
target_link_libraries(jobs_example PRIVATE databricks_sdk)

# ========== Connection Pooling Examples ==========
add_executable(transparent_pooling pooling/transparent_pooling.cpp)
target_link_libraries(transparent_pooling PRIVATE databricks_sdk)
Expand All @@ -33,6 +36,7 @@ set_target_properties(
benchmark
async_operations
pool_async_combined
jobs_example
PROPERTIES
BUILD_RPATH "${CMAKE_BINARY_DIR};/opt/homebrew/lib;/usr/local/lib"
INSTALL_RPATH "/opt/homebrew/lib;/usr/local/lib"
Expand Down
2 changes: 1 addition & 1 deletion examples/async/async_operations.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <databricks/client.h>
#include <databricks/core/client.h>
#include "../common/config_helper.h"
#include <iostream>
#include <chrono>
Expand Down
2 changes: 1 addition & 1 deletion examples/async/pool_async_combined.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <databricks/client.h>
#include <databricks/core/client.h>
#include <databricks/connection_pool.h>
#include "../common/config_helper.h"
#include <iostream>
Expand Down
Loading