dremio-cli 1.0.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dremio_cli-1.0.0/dremio_cli.egg-info → dremio_cli-1.2.0}/PKG-INFO +1 -1
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/installation.md +3 -3
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/sql.md +7 -10
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/client/cloud.py +11 -1
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/sql.py +31 -4
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/env.py +15 -3
- {dremio_cli-1.0.0 → dremio_cli-1.2.0/dremio_cli.egg-info}/PKG-INFO +1 -1
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/pyproject.toml +1 -1
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/LICENSE +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/MANIFEST.in +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/README.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/completions/dremio-completion.bash +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/completions/dremio-completion.zsh +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/README.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/advanced-features.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/catalog.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/grants.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/jobs.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/profiles.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/quickstart.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/roles.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/sources.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/spaces-folders.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/tables.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/tags-wiki.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/users.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/docs/views.md +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/__init__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/__main__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/cli.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/client/__init__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/client/auth.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/client/base.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/client/factory.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/client/software.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/__init__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/catalog.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/favorite.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/folder.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/grant.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/history.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/job.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/lineage.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/profile.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/role.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/source.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/space.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/table.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/tag.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/udf.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/user.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/view.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/commands/wiki.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/config.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/formatters/__init__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/formatters/json.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/formatters/table.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/formatters/yaml.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/history.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/utils/__init__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/utils/exceptions.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/utils/helpers.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli/utils/validators.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli.egg-info/SOURCES.txt +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli.egg-info/dependency_links.txt +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli.egg-info/entry_points.txt +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli.egg-info/requires.txt +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/dremio_cli.egg-info/top_level.txt +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/setup.cfg +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/setup.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/__init__.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_config.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_grant_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_history_favorite.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_integration.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_job_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_role_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_source_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_space_folder_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_sql_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_table_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_tag_wiki_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_user_commands.py +0 -0
- {dremio_cli-1.0.0 → dremio_cli-1.2.0}/tests/test_view_commands.py +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Requirements
|
|
4
4
|
|
|
5
|
-
- Python 3.
|
|
5
|
+
- Python 3.8 or higher
|
|
6
6
|
- pip or pipx
|
|
7
7
|
|
|
8
8
|
## Installation Methods
|
|
@@ -22,7 +22,7 @@ pipx install dremio-cli
|
|
|
22
22
|
### From Source (For developers)
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
git clone https://github.com/
|
|
25
|
+
git clone https://github.com/developer-advocacy-dremio/dremio-python-cli
|
|
26
26
|
cd dremio-cli
|
|
27
27
|
pip install -e .
|
|
28
28
|
```
|
|
@@ -30,7 +30,7 @@ pip install -e .
|
|
|
30
30
|
### Development Installation
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
git clone https://github.com/
|
|
33
|
+
git clone https://github.com/developer-advocacy-dremio/dremio-python-cli
|
|
34
34
|
cd dremio-cli
|
|
35
35
|
pip install -e ".[dev]"
|
|
36
36
|
```
|
|
@@ -19,22 +19,19 @@ dremio sql execute --file <FILE> [OPTIONS]
|
|
|
19
19
|
**Options:**
|
|
20
20
|
- `--file PATH` - Execute SQL from file
|
|
21
21
|
- `--context TEXT` - Query context (comma-separated path)
|
|
22
|
-
- `--async` - Execute asynchronously (return job ID immediately)
|
|
22
|
+
- `--async` - Execute asynchronously (return job ID immediately). Default behavior waits for results.
|
|
23
23
|
- `--output-file PATH` - Save results to file
|
|
24
24
|
|
|
25
25
|
**Examples:**
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
# Execute simple query
|
|
28
|
+
# Execute simple query (Waits for results)
|
|
29
29
|
dremio sql execute "SELECT * FROM customers LIMIT 10"
|
|
30
30
|
|
|
31
|
-
# Execute from file
|
|
31
|
+
# Execute from file (Waits for results)
|
|
32
32
|
dremio sql execute --file query.sql
|
|
33
33
|
|
|
34
|
-
# Execute
|
|
35
|
-
dremio sql execute "SELECT * FROM table" --context "MySpace"
|
|
36
|
-
|
|
37
|
-
# Async execution (for long-running queries)
|
|
34
|
+
# Execute asynchronously (Returns Job ID immediately)
|
|
38
35
|
dremio sql execute "SELECT * FROM large_table" --async
|
|
39
36
|
|
|
40
37
|
# Save results to file
|
|
@@ -421,9 +418,9 @@ dremio job get <job-id>
|
|
|
421
418
|
- All features available
|
|
422
419
|
|
|
423
420
|
### Cloud
|
|
424
|
-
-
|
|
425
|
-
-
|
|
426
|
-
-
|
|
421
|
+
- SELECT queries are fully supported via API
|
|
422
|
+
- DDL/DML operations are supported but may have limitations compared to Software
|
|
423
|
+
- Uses specialized generic SQL endpoint
|
|
427
424
|
|
|
428
425
|
## Best Practices
|
|
429
426
|
|
|
@@ -35,7 +35,9 @@ class CloudClient(BaseClient):
|
|
|
35
35
|
Returns:
|
|
36
36
|
Project-scoped endpoint
|
|
37
37
|
"""
|
|
38
|
-
|
|
38
|
+
# Ensure v0 prefix for Cloud API (it's required for projects endpoints)
|
|
39
|
+
prefix = "" if "/v0" in self.base_url else "/v0"
|
|
40
|
+
return f"{prefix}/projects/{self.project_id}/{endpoint.lstrip('/')}"
|
|
39
41
|
|
|
40
42
|
# Catalog operations
|
|
41
43
|
def get_catalog(self, include: Optional[str] = None) -> Dict[str, Any]:
|
|
@@ -66,6 +68,14 @@ class CloudClient(BaseClient):
|
|
|
66
68
|
"""Delete a source."""
|
|
67
69
|
return self.delete(self._project_endpoint(f"catalog/{source_id}"))
|
|
68
70
|
|
|
71
|
+
# SQL operations
|
|
72
|
+
def execute_sql(self, sql: str, context: Optional[list] = None) -> Dict[str, Any]:
|
|
73
|
+
"""Execute SQL query."""
|
|
74
|
+
data = {"sql": sql}
|
|
75
|
+
if context:
|
|
76
|
+
data["context"] = context
|
|
77
|
+
return self.post(self._project_endpoint("sql"), data=data)
|
|
78
|
+
|
|
69
79
|
# Job operations
|
|
70
80
|
def list_jobs(
|
|
71
81
|
self,
|
|
@@ -67,19 +67,46 @@ def execute_sql(ctx, query: str, sql_file: str, context: str, async_mode: bool,
|
|
|
67
67
|
with console.status(f"[bold green]Executing SQL query..."):
|
|
68
68
|
result = client.execute_sql(query, context=sql_context)
|
|
69
69
|
|
|
70
|
+
# Check if result is a dictionary (it might be a string error message)
|
|
71
|
+
if not isinstance(result, dict):
|
|
72
|
+
console.print(f"[red]Error: Unexpected response from Dremio API:[/red]")
|
|
73
|
+
console.print(f"{result}")
|
|
74
|
+
raise click.Abort()
|
|
75
|
+
|
|
70
76
|
job_id = result.get("id")
|
|
71
77
|
|
|
72
78
|
if async_mode:
|
|
73
79
|
# Return job ID immediately
|
|
74
|
-
console.print(f"[green]✓[/green] Query submitted")
|
|
80
|
+
console.print(f"[green]✓[/green] Query submitted (Async)")
|
|
75
81
|
console.print(f" Job ID: {job_id}")
|
|
76
|
-
|
|
77
|
-
console.print(f"[
|
|
82
|
+
# Display full command for user convenience
|
|
83
|
+
console.print(f"\n[bold]Check status and results:[/bold]")
|
|
84
|
+
console.print(f" dremio job results {job_id}")
|
|
78
85
|
else:
|
|
79
86
|
# Wait for results
|
|
80
|
-
|
|
87
|
+
import time
|
|
88
|
+
from dremio_cli.client.cloud import CloudClient
|
|
89
|
+
|
|
90
|
+
console.print(f"[green]✓[/green] Query submitted. Waiting for completion...")
|
|
81
91
|
console.print(f" Job ID: {job_id}")
|
|
82
92
|
|
|
93
|
+
# Polling loop
|
|
94
|
+
with console.status(f"[bold green]Job {job_id} is running...[/bold green]", spinner="dots") as status:
|
|
95
|
+
while True:
|
|
96
|
+
job_info = client.get_job(job_id)
|
|
97
|
+
job_state = job_info.get("jobState")
|
|
98
|
+
|
|
99
|
+
if job_state == "COMPLETED":
|
|
100
|
+
break
|
|
101
|
+
elif job_state in ["FAILED", "CANCELED"]:
|
|
102
|
+
console.print(f"[red]Job {job_state}[/red]")
|
|
103
|
+
err_msg = job_info.get("errorMessage", "Unknown error")
|
|
104
|
+
console.print(f"Error: {err_msg}")
|
|
105
|
+
raise click.Abort()
|
|
106
|
+
|
|
107
|
+
# Wait before next poll
|
|
108
|
+
time.sleep(1.0)
|
|
109
|
+
|
|
83
110
|
# Get job results
|
|
84
111
|
if job_id:
|
|
85
112
|
try:
|
|
@@ -21,12 +21,24 @@ def load_dotenv(dotenv_path: Optional[Path] = None) -> None:
|
|
|
21
21
|
"""Load environment variables from .env file.
|
|
22
22
|
|
|
23
23
|
Args:
|
|
24
|
-
dotenv_path: Path to .env file. If None, looks in current directory.
|
|
24
|
+
dotenv_path: Path to .env file. If None, looks in current directory and repo root.
|
|
25
25
|
"""
|
|
26
26
|
if dotenv_path is None:
|
|
27
|
-
|
|
27
|
+
# Check locations in order:
|
|
28
|
+
# 1. Current working directory
|
|
29
|
+
# 2. Project root (relative to this file: dremio_cli/env.py -> ../../.env)
|
|
30
|
+
|
|
31
|
+
candidates = [
|
|
32
|
+
Path.cwd() / ".env",
|
|
33
|
+
Path(__file__).resolve().parent.parent.parent / ".env"
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
for path in candidates:
|
|
37
|
+
if path.exists():
|
|
38
|
+
dotenv_path = path
|
|
39
|
+
break
|
|
28
40
|
|
|
29
|
-
if not dotenv_path.exists():
|
|
41
|
+
if dotenv_path is None or not dotenv_path.exists():
|
|
30
42
|
return
|
|
31
43
|
|
|
32
44
|
with open(dotenv_path, "r") as f:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|