kaqing 2.0.99__tar.gz → 2.0.101__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.
Potentially problematic release.
This version of kaqing might be problematic. Click here for more details.
- {kaqing-2.0.99 → kaqing-2.0.101}/PKG-INFO +1 -1
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/alter_tables.py +3 -7
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/audit/audit.py +3 -2
- kaqing-2.0.101/adam/commands/audit/audit_table_completer.py +9 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/describe.py +18 -4
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/describe_keyspace.py +2 -4
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/describe_keyspaces.py +1 -4
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/describe_schema.py +1 -4
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/describe_table.py +3 -6
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/describe_tables.py +1 -4
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/ls.py +1 -1
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/preview_table.py +11 -3
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/embedded_params.py +1 -1
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/repl.py +72 -41
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sql/sql_completer.py +2 -1
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sql/state_machine.py +28 -1
- kaqing-2.0.101/adam/version.py +5 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-2.0.99 → kaqing-2.0.101}/kaqing.egg-info/SOURCES.txt +1 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/setup.py +1 -1
- kaqing-2.0.99/adam/version.py +0 -5
- {kaqing-2.0.99 → kaqing-2.0.101}/README +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/app_session.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/apps.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/batch.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/check.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/check_context.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/check_result.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/check_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/compactionstats.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/cpu.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/disk.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/gossip.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/issue.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/memory.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/checks/status.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/cli.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/cli_group.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/column.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/columns.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/compactions.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/cpu.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/dir_data.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/gossip.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/host_id.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/memory.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/node_address.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/node_load.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/node_owns.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/node_status.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/node_tokens.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/node_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/pod_name.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/columns/volume_root.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/app.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/app_ping.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/audit/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/audit/audit_repair_tables.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/bash.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cd.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/check.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cli_commands.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/command.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/command_helpers.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/commands_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cp.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cql/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cql/cql_completions.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cql/cql_table_completer.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cql/cql_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/cql/cqlsh.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/deploy.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/deploy_pg_agent.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/deploy_pod.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/deploy_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/undeploy.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/undeploy_pg_agent.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/deploy/undeploy_pod.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/describe/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/devices.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/exit.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/help.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/issues.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/login.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/logs.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/nodetool.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/param_get.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/param_set.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/postgres.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/postgres_session.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/postgres_utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/psql_completions.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/postgres/psql_table_completer.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/pwd.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/repair/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/repair/repair.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/report.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/restart.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/rollout.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/shell.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_adam.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_commands.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_host.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_login.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_params.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_processes.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/show/show_storage.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/commands/watch.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/config.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/embedded_apps.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/log.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/pod_exec_result.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/repl_commands.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/repl_session.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/repl_state.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sql/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sql/term_completer.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/authenticator.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/authn_ad.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/authn_okta.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/cred_cache.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/id_token.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/idp.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/idp_login.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/idp_session.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/sso/sso_config.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_athena.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/__init__.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/cassandra_clusters.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/cassandra_nodes.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/config_maps.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/custom_resources.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/deployment.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/ingresses.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/jobs.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/kube_context.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/pods.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/secrets.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/service_accounts.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/services.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/statefulsets.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_k8s/volumes.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/adam/utils_net.py +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-2.0.99 → kaqing-2.0.101}/setup.cfg +0 -0
|
@@ -43,11 +43,6 @@ class AlterTables(Command):
|
|
|
43
43
|
args, include_reaper = Command.extract_options(args, '--include-reaper')
|
|
44
44
|
arg_str = ' '.join(args)
|
|
45
45
|
|
|
46
|
-
# r: list[PodExecResult] = run_cql(state, 'describe tables', show_out=False, on_any=True)
|
|
47
|
-
# if not r:
|
|
48
|
-
# log2('No pod is available')
|
|
49
|
-
# return 'no-pod'
|
|
50
|
-
|
|
51
46
|
excludes = [e.strip(' \r\n') for e in Config().get(
|
|
52
47
|
'cql.alter-tables.excludes',
|
|
53
48
|
'system_auth,system_traces,reaper_db,system_distributed,system_views,system,system_schema,system_virtual_schema').split(',')]
|
|
@@ -78,8 +73,9 @@ class AlterTables(Command):
|
|
|
78
73
|
# do not continue to cql route
|
|
79
74
|
return state
|
|
80
75
|
|
|
81
|
-
def completion(self,
|
|
76
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
77
|
+
# auto completion is taken care of by sql completer
|
|
82
78
|
return {}
|
|
83
79
|
|
|
84
80
|
def help(self, _: ReplState) -> str:
|
|
85
|
-
return f'{AlterTables.COMMAND} <param = value> [--include-reaper] \t alter on all tables'
|
|
81
|
+
return f'{AlterTables.COMMAND} <param = value> [--include-reaper] \t alter schema on all tables'
|
|
@@ -62,8 +62,9 @@ class Audit(Command):
|
|
|
62
62
|
columns=lambda table: audit_column_names(),
|
|
63
63
|
partition_columns=lambda table: audit_column_names(partition_cols_only=True),
|
|
64
64
|
variant='athena'
|
|
65
|
-
)
|
|
66
|
-
|
|
65
|
+
)
|
|
66
|
+
# | {
|
|
67
|
+
# 'desc': {table: None for table in audit_table_names()}}
|
|
67
68
|
|
|
68
69
|
return {}
|
|
69
70
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from adam.sql.term_completer import TermCompleter
|
|
2
|
+
from adam.utils_athena import audit_table_names
|
|
3
|
+
|
|
4
|
+
class AuditTableNameCompleter(TermCompleter):
|
|
5
|
+
def __init__(self, ignore_case: bool = True):
|
|
6
|
+
super().__init__(audit_table_names(), ignore_case=ignore_case)
|
|
7
|
+
|
|
8
|
+
def __repr__(self) -> str:
|
|
9
|
+
return "AuditTableCompleter()"
|
|
@@ -7,6 +7,8 @@ from adam.commands.describe.describe_schema import DescribeSchema
|
|
|
7
7
|
from adam.commands.describe.describe_table import DescribeTable
|
|
8
8
|
from adam.commands.describe.describe_tables import DescribeTables
|
|
9
9
|
from adam.repl_state import ReplState, RequiredState
|
|
10
|
+
from adam.utils import log2
|
|
11
|
+
from adam.utils_athena import run_audit_query
|
|
10
12
|
|
|
11
13
|
class Describe(Command):
|
|
12
14
|
COMMAND = 'describe'
|
|
@@ -31,15 +33,27 @@ class Describe(Command):
|
|
|
31
33
|
if not(args := self.args(cmd)):
|
|
32
34
|
return super().run(cmd, state)
|
|
33
35
|
|
|
36
|
+
if state.device == ReplState.L:
|
|
37
|
+
state, args = self.apply_state(args, state)
|
|
38
|
+
if not args:
|
|
39
|
+
if state.in_repl:
|
|
40
|
+
log2('Please enter table name')
|
|
41
|
+
else:
|
|
42
|
+
log2('* table name is missing.')
|
|
43
|
+
log2()
|
|
44
|
+
Command.display_help()
|
|
45
|
+
return state
|
|
46
|
+
|
|
47
|
+
run_audit_query(f'describe {args[0]}')
|
|
48
|
+
|
|
49
|
+
return state
|
|
50
|
+
|
|
34
51
|
return super().intermediate_run(cmd, state, args, Describe.cmd_list())
|
|
35
52
|
|
|
36
53
|
def cmd_list():
|
|
37
54
|
return [DescribeKeyspace(), DescribeKeyspaces(), DescribeSchema(), DescribeTable(), DescribeTables()]
|
|
38
55
|
|
|
39
|
-
def completion(self,
|
|
40
|
-
if state.sts:
|
|
41
|
-
return super().completion(state)
|
|
42
|
-
|
|
56
|
+
def completion(self, _: ReplState):
|
|
43
57
|
return {}
|
|
44
58
|
|
|
45
59
|
class DescribeCommandHelper(click.Command):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.commands.cql.cql_utils import
|
|
2
|
+
from adam.commands.cql.cql_utils import run_cql
|
|
3
3
|
from adam.pod_exec_result import PodExecResult
|
|
4
4
|
from adam.repl_state import ReplState, RequiredState
|
|
5
5
|
from adam.utils import log2
|
|
@@ -50,9 +50,7 @@ class DescribeKeyspace(Command):
|
|
|
50
50
|
# do not continue to cql route
|
|
51
51
|
return state
|
|
52
52
|
|
|
53
|
-
def completion(self,
|
|
54
|
-
if state.sts:
|
|
55
|
-
return super().completion(state, {ks: {'&': None} for ks in keyspaces(state, on_any=True)})
|
|
53
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
56
54
|
|
|
57
55
|
return {}
|
|
58
56
|
|
|
@@ -39,10 +39,7 @@ class DescribeKeyspaces(Command):
|
|
|
39
39
|
# do not continue to cql route
|
|
40
40
|
return state
|
|
41
41
|
|
|
42
|
-
def completion(self,
|
|
43
|
-
if state.sts:
|
|
44
|
-
return super().completion(state, {'&': None})
|
|
45
|
-
|
|
42
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
46
43
|
return {}
|
|
47
44
|
|
|
48
45
|
def help(self, _: ReplState) -> str:
|
|
@@ -39,10 +39,7 @@ class DescribeSchema(Command):
|
|
|
39
39
|
# do not continue to cql route
|
|
40
40
|
return state
|
|
41
41
|
|
|
42
|
-
def completion(self,
|
|
43
|
-
if state.sts:
|
|
44
|
-
return super().completion(state, {'&': None})
|
|
45
|
-
|
|
42
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
46
43
|
return {}
|
|
47
44
|
|
|
48
45
|
def help(self, _: ReplState) -> str:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.commands.cql.cql_utils import run_cql
|
|
2
|
+
from adam.commands.cql.cql_utils import run_cql
|
|
3
3
|
from adam.pod_exec_result import PodExecResult
|
|
4
4
|
from adam.repl_state import ReplState, RequiredState
|
|
5
5
|
from adam.utils import log2
|
|
@@ -50,11 +50,8 @@ class DescribeTable(Command):
|
|
|
50
50
|
# do not continue to cql route
|
|
51
51
|
return state
|
|
52
52
|
|
|
53
|
-
def completion(self,
|
|
54
|
-
if state.sts:
|
|
55
|
-
return super().completion(state, {t: {'&': None} for t in table_names(state)})
|
|
56
|
-
|
|
53
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
57
54
|
return {}
|
|
58
55
|
|
|
59
56
|
def help(self, _: ReplState) -> str:
|
|
60
|
-
return f'{DescribeTable.COMMAND} <table-name> [&]\t describe Cassandra table'
|
|
57
|
+
return f'{DescribeTable.COMMAND} <table-name> [&]\t describe Cassandra or Athena table'
|
|
@@ -39,10 +39,7 @@ class DescribeTables(Command):
|
|
|
39
39
|
# do not continue to cql route
|
|
40
40
|
return state
|
|
41
41
|
|
|
42
|
-
def completion(self,
|
|
43
|
-
if state.sts:
|
|
44
|
-
return super().completion(state, {'&': None})
|
|
45
|
-
|
|
42
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
46
43
|
return {}
|
|
47
44
|
|
|
48
45
|
def help(self, _: ReplState) -> str:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
|
|
3
|
+
from adam.commands.audit.audit_table_completer import AuditTableNameCompleter
|
|
3
4
|
from adam.commands.command import Command
|
|
4
5
|
from adam.commands.cql.cql_table_completer import CqlTableNameCompleter
|
|
5
6
|
from adam.commands.cql.cql_utils import run_cql, table_names, tables
|
|
@@ -8,6 +9,7 @@ from adam.commands.postgres.psql_table_completer import PsqlTableNameCompleter
|
|
|
8
9
|
from adam.config import Config
|
|
9
10
|
from adam.repl_state import ReplState, RequiredState
|
|
10
11
|
from adam.utils import lines_to_tabular, log, log2
|
|
12
|
+
from adam.utils_athena import audit_table_names, run_audit_query
|
|
11
13
|
|
|
12
14
|
class PreviewTable(Command):
|
|
13
15
|
COMMAND = 'preview'
|
|
@@ -35,7 +37,7 @@ class PreviewTable(Command):
|
|
|
35
37
|
if state.device == ReplState.P:
|
|
36
38
|
if not self.validate_state(state, RequiredState.PG_DATABASE):
|
|
37
39
|
return state
|
|
38
|
-
|
|
40
|
+
elif state.device != ReplState.L:
|
|
39
41
|
if not self.validate_state(state):
|
|
40
42
|
return state
|
|
41
43
|
|
|
@@ -45,8 +47,10 @@ class PreviewTable(Command):
|
|
|
45
47
|
pg = PostgresSession(state.namespace, state.pg_path)
|
|
46
48
|
lines = [db["name"] for db in pg.tables() if db["schema"] == PostgresSession.default_schema()]
|
|
47
49
|
log(lines_to_tabular(lines, separator=','))
|
|
50
|
+
elif state.device == ReplState.L:
|
|
51
|
+
log(lines_to_tabular(audit_table_names(), separator=','))
|
|
48
52
|
else:
|
|
49
|
-
run_cql(state, f'describe tables', show_out=True)
|
|
53
|
+
run_cql(state, f'describe tables', show_out=True, on_any=True)
|
|
50
54
|
|
|
51
55
|
if state.in_repl:
|
|
52
56
|
log2('Table is required.')
|
|
@@ -66,14 +70,18 @@ class PreviewTable(Command):
|
|
|
66
70
|
rows = Config().get('preview.rows', 10)
|
|
67
71
|
if state.device == ReplState.P:
|
|
68
72
|
PostgresSession(state.namespace, state.pg_path).run_sql(f'select * from {table} limit {rows}')
|
|
73
|
+
elif state.device == ReplState.L:
|
|
74
|
+
run_audit_query(f'select * from {table} limit {rows}')
|
|
69
75
|
else:
|
|
70
|
-
run_cql(state, f'select * from {table} limit {rows}', show_out=True, use_single_quotes=True)
|
|
76
|
+
run_cql(state, f'select * from {table} limit {rows}', show_out=True, use_single_quotes=True, on_any=True)
|
|
71
77
|
|
|
72
78
|
return state
|
|
73
79
|
|
|
74
80
|
def completion(self, state: ReplState):
|
|
75
81
|
if state.device == ReplState.P:
|
|
76
82
|
return {PreviewTable.COMMAND: PsqlTableNameCompleter(state.namespace, state.pg_path)}
|
|
83
|
+
elif state.device == ReplState.L:
|
|
84
|
+
return {PreviewTable.COMMAND: AuditTableNameCompleter()}
|
|
77
85
|
elif state.sts:
|
|
78
86
|
return {PreviewTable.COMMAND: CqlTableNameCompleter(table_names(state))}
|
|
79
87
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
def config():
|
|
2
|
-
return {'app': {'console-endpoint': 'https://{host}/{env}/{app}/static/console/index.html', 'cr': {'cluster-regex': '(.*?-.*?)-.*', 'group': 'ops.c3.ai', 'v': 'v2', 'plural': 'c3cassandras'}, 'label': 'c3__app_id-0', 'login': {'admin-group': '{host}/C3.ClusterAdmin', 'ingress': '{app_id}-k8singr-appleader-001', 'timeout': 5, 'session-check-url': 'https://{host}/{env}/{app}/api/8/C3/userSessionToken', 'cache-creds': True, 'cache-username': True, 'url': 'https://{host}/{env}/{app}', 'another': "You're logged in to {has}. However, for this app, you need to log in to {need}.", 'token-server-url': 'http://localhost:{port}', 'password-max-length': 128}, 'strip': '0'}, 'audit': {'endpoint': 'https://4psvtaxlcb.execute-api.us-west-2.amazonaws.com/prod/', 'workers': 3, 'timeout': 10, 'log-audit-queries': False, 'athena': {'auto-repair': {'elapsed_hours': 12}, 'region': 'us-west-2', 'catalog': 'AwsDataCatalog', 'database': 'audit', 'tables': 'audit', 'output': 's3://s3.ops--audit/ddl/results'}}, 'bash': {'workers': 32}, 'cassandra': {'service-name': 'all-pods-service'}, 'cql': {'workers': 32, 'samples': 3, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-superuser', 'password-item': 'password'}, 'alter-tables': {'excludes': 'system_auth,system_traces,reaper_db,system_distributed,system_views,system,system_schema,system_virtual_schema', 'gc-grace-periods': '3600,86400,864000,7776000', 'batching': True}}, 'checks': {'compactions-threshold': 250, 'cpu-busy-threshold': 98.0, 'cpu-threshold': 0.0, 'cassandra-data-path': '/c3/cassandra', 'root-disk-threshold': 50, 'cassandra-disk-threshold': 50, 'snapshot-size-cmd': "ls /c3/cassandra/data/data/*/*/snapshots | grep snapshots | sed 's/:$//g' | xargs -I {} du -sk {} | awk '{print $1}' | awk '{s+=$1} END {print s}'", 'snapshot-size-threshold': '40G', 'table-sizes-cmd': "ls -Al /c3/cassandra/data/data/ | awk '{print $9}' | sed 's/\\^r//g' | xargs -I {} du -sk /c3/cassandra/data/data/{}"}, 'get-host-id': {'workers': 32}, 'idps': {'ad': {'email-pattern': '.*@c3.ai', 'uri': 'https://login.microsoftonline.com/53ad779a-93e7-485c-ba20-ac8290d7252b/oauth2/v2.0/authorize?response_type=id_token&response_mode=form_post&client_id=00ff94a8-6b0a-4715-98e0-95490012d818&scope=openid+email+profile&redirect_uri=https%3A%2F%2Fplat.c3ci.cloud%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://login.microsoftonline.com/common/discovery/keys', 'contact': 'Please contact ted.tran@c3.ai.', 'whitelist-file': '/kaqing/members'}, 'okta': {'default': True, 'email-pattern': '.*@c3iot.com', 'uri': 'https://c3energy.okta.com/oauth2/v1/authorize?response_type=id_token&response_mode=form_post&client_id={client_id}&scope=openid+email+profile+groups&redirect_uri=https%3A%2F%2F{host}%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://c3energy.okta.com/oauth2/v1/keys'}}, 'issues': {'workers': 32}, 'logs': {'path': '/c3/cassandra/logs/system.log'}, 'medusa': {'restore-auto-complete': False}, 'nodetool': {'workers': 32, 'samples': 3, 'commands_in_line': 40}, 'pg': {'name-pattern': '^{namespace}.*-k8spg-.*', 'excludes': '.helm., -admin-secret', 'agent': {'name': 'ops-pg-agent', 'just-in-time': False, 'timeout': 86400, 'image': 'seanahnsf/kaqing'}, 'default-db': 'postgres', 'default-schema': 'postgres', 'secret': {'endpoint-key': 'postgres-db-endpoint', 'port-key': 'postgres-db-port', 'username-key': 'postgres-admin-username', 'password-key': 'postgres-admin-password'}}, 'pod': {'name': 'ops', 'image': 'seanahnsf/kaqing-cloud', 'sa': {'name': 'ops', 'proto': 'c3', 'additional-cluster-roles': 'c3aiops-k8ssandra-operator'}, 'label-selector': 'run=ops'}, 'preview': {'rows': 10}, 'processes': {'columns': 'pod,cpu,mem', 'header': 'POD_NAME,CPU,MEM/LIMIT'}, 'reaper': {'service-name': 'reaper-service', 'port-forward': {'timeout': 86400, 'local-port': 9001}, 'abort-runs-batch': 10, 'show-runs-batch': 100, 'pod': {'cluster-regex': '(.*?-.*?-.*?-.*?)-.*', 'label-selector': 'k8ssandra.io/reaper={cluster}-reaper'}, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-reaper-ui', 'password-item': 'password'}}, 'repair': {'log-path': '/home/cassrepair/logs/', 'image': 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.14', 'secret': 'ciregistryc3iotio', 'env': {'interval': 24, 'timeout': 60, 'pr': False, 'runs': 1}}, 'repl': {'start-drive': 'a', 'auto-enter
|
|
2
|
+
return {'app': {'console-endpoint': 'https://{host}/{env}/{app}/static/console/index.html', 'cr': {'cluster-regex': '(.*?-.*?)-.*', 'group': 'ops.c3.ai', 'v': 'v2', 'plural': 'c3cassandras'}, 'label': 'c3__app_id-0', 'login': {'admin-group': '{host}/C3.ClusterAdmin', 'ingress': '{app_id}-k8singr-appleader-001', 'timeout': 5, 'session-check-url': 'https://{host}/{env}/{app}/api/8/C3/userSessionToken', 'cache-creds': True, 'cache-username': True, 'url': 'https://{host}/{env}/{app}', 'another': "You're logged in to {has}. However, for this app, you need to log in to {need}.", 'token-server-url': 'http://localhost:{port}', 'password-max-length': 128}, 'strip': '0'}, 'audit': {'endpoint': 'https://4psvtaxlcb.execute-api.us-west-2.amazonaws.com/prod/', 'workers': 3, 'timeout': 10, 'log-audit-queries': False, 'athena': {'auto-repair': {'elapsed_hours': 12}, 'region': 'us-west-2', 'catalog': 'AwsDataCatalog', 'database': 'audit', 'tables': 'audit', 'output': 's3://s3.ops--audit/ddl/results'}}, 'bash': {'workers': 32}, 'cassandra': {'service-name': 'all-pods-service'}, 'cql': {'workers': 32, 'samples': 3, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-superuser', 'password-item': 'password'}, 'alter-tables': {'excludes': 'system_auth,system_traces,reaper_db,system_distributed,system_views,system,system_schema,system_virtual_schema', 'gc-grace-periods': '3600,86400,864000,7776000', 'batching': True}}, 'checks': {'compactions-threshold': 250, 'cpu-busy-threshold': 98.0, 'cpu-threshold': 0.0, 'cassandra-data-path': '/c3/cassandra', 'root-disk-threshold': 50, 'cassandra-disk-threshold': 50, 'snapshot-size-cmd': "ls /c3/cassandra/data/data/*/*/snapshots | grep snapshots | sed 's/:$//g' | xargs -I {} du -sk {} | awk '{print $1}' | awk '{s+=$1} END {print s}'", 'snapshot-size-threshold': '40G', 'table-sizes-cmd': "ls -Al /c3/cassandra/data/data/ | awk '{print $9}' | sed 's/\\^r//g' | xargs -I {} du -sk /c3/cassandra/data/data/{}"}, 'get-host-id': {'workers': 32}, 'idps': {'ad': {'email-pattern': '.*@c3.ai', 'uri': 'https://login.microsoftonline.com/53ad779a-93e7-485c-ba20-ac8290d7252b/oauth2/v2.0/authorize?response_type=id_token&response_mode=form_post&client_id=00ff94a8-6b0a-4715-98e0-95490012d818&scope=openid+email+profile&redirect_uri=https%3A%2F%2Fplat.c3ci.cloud%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://login.microsoftonline.com/common/discovery/keys', 'contact': 'Please contact ted.tran@c3.ai.', 'whitelist-file': '/kaqing/members'}, 'okta': {'default': True, 'email-pattern': '.*@c3iot.com', 'uri': 'https://c3energy.okta.com/oauth2/v1/authorize?response_type=id_token&response_mode=form_post&client_id={client_id}&scope=openid+email+profile+groups&redirect_uri=https%3A%2F%2F{host}%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://c3energy.okta.com/oauth2/v1/keys'}}, 'issues': {'workers': 32}, 'logs': {'path': '/c3/cassandra/logs/system.log'}, 'medusa': {'restore-auto-complete': False}, 'nodetool': {'workers': 32, 'samples': 3, 'commands_in_line': 40}, 'pg': {'name-pattern': '^{namespace}.*-k8spg-.*', 'excludes': '.helm., -admin-secret', 'agent': {'name': 'ops-pg-agent', 'just-in-time': False, 'timeout': 86400, 'image': 'seanahnsf/kaqing'}, 'default-db': 'postgres', 'default-schema': 'postgres', 'secret': {'endpoint-key': 'postgres-db-endpoint', 'port-key': 'postgres-db-port', 'username-key': 'postgres-admin-username', 'password-key': 'postgres-admin-password'}}, 'pod': {'name': 'ops', 'image': 'seanahnsf/kaqing-cloud', 'sa': {'name': 'ops', 'proto': 'c3', 'additional-cluster-roles': 'c3aiops-k8ssandra-operator'}, 'label-selector': 'run=ops'}, 'preview': {'rows': 10}, 'processes': {'columns': 'pod,cpu,mem', 'header': 'POD_NAME,CPU,MEM/LIMIT'}, 'reaper': {'service-name': 'reaper-service', 'port-forward': {'timeout': 86400, 'local-port': 9001}, 'abort-runs-batch': 10, 'show-runs-batch': 100, 'pod': {'cluster-regex': '(.*?-.*?-.*?-.*?)-.*', 'label-selector': 'k8ssandra.io/reaper={cluster}-reaper'}, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-reaper-ui', 'password-item': 'password'}}, 'repair': {'log-path': '/home/cassrepair/logs/', 'image': 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.14', 'secret': 'ciregistryc3iotio', 'env': {'interval': 24, 'timeout': 60, 'pr': False, 'runs': 1}}, 'repl': {'start-drive': 'a', 'a': {'auto-enter': 'c3/c3'}, 'c': {'auto-enter': 'cluster'}, 'history': {'push-cat-remote-log-file': True}, 'background-process': {'auto-nohup': True}}, 'status': {'columns': 'status,address,load,tokens,owns,host_id,gossip,compactions', 'header': '--,Address,Load,Tokens,Owns,Host ID,GOSSIP,COMPACTIONS'}, 'storage': {'columns': 'pod,volume_root,volume_cassandra,snapshots,data,compactions', 'header': 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS'}, 'watch': {'auto': 'rollout', 'timeout': 3600, 'interval': 10}, 'debug': False, 'debugs': {'timings': False, 'exit-on-error': False, 'show-parallelism': False}}
|
|
@@ -69,23 +69,24 @@ def enter_repl(state: ReplState):
|
|
|
69
69
|
Log.log2(f'kaqing {__version__}')
|
|
70
70
|
|
|
71
71
|
if state.device == ReplState.C:
|
|
72
|
-
auto_enter = Config().get('repl.auto-enter
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
auto_enter = Config().get('repl.c.auto-enter', 'cluster')
|
|
73
|
+
if auto_enter and auto_enter in ['cluster', 'first-pod']:
|
|
74
|
+
ss = StatefulSets.list_sts_name_and_ns()
|
|
75
|
+
if not ss:
|
|
76
|
+
log2("No Cassandra clusters found.")
|
|
77
|
+
elif not state.sts and len(ss) == 1:
|
|
78
|
+
cluster = ss[0]
|
|
79
|
+
state.sts = cluster[0]
|
|
80
|
+
state.namespace = cluster[1]
|
|
81
|
+
if auto_enter == 'first-pod':
|
|
82
|
+
state.pod = f'{state.sts}-0'
|
|
83
|
+
if KubeContext().in_cluster_namespace:
|
|
84
|
+
Config().wait_log(f'Moving to the only Cassandra cluster: {state.sts}...')
|
|
85
|
+
else:
|
|
86
|
+
Config().wait_log(f'Moving to the only Cassandra cluster: {state.sts}@{state.namespace}...')
|
|
86
87
|
elif state.device == ReplState.A:
|
|
87
88
|
if not state.app_env:
|
|
88
|
-
if app := Config().get('repl.auto-enter-app', 'c3/c3'):
|
|
89
|
+
if app := Config().get('repl.a.auto-enter-app', 'c3/c3'):
|
|
89
90
|
if app != 'no':
|
|
90
91
|
ea = app.split('/')
|
|
91
92
|
state.app_env = ea[0]
|
|
@@ -140,32 +141,34 @@ def enter_repl(state: ReplState):
|
|
|
140
141
|
cmd = f'bash {cmd}'
|
|
141
142
|
|
|
142
143
|
if cmd and cmd.strip(' ') and not cmds.run(cmd, state):
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
try_device_default_action(state, cmds, cmd_list)
|
|
145
|
+
# not served by any command in the chain; try SQL query or C3 action
|
|
146
|
+
# c_sql_tried = False
|
|
147
|
+
# if state.device == ReplState.P:
|
|
148
|
+
# pg = PostgresSession(state.namespace, state.pg_path)
|
|
149
|
+
# if pg.db:
|
|
150
|
+
# c_sql_tried = True
|
|
151
|
+
# cmd = f'pg {cmd}'
|
|
152
|
+
# cmds.run(cmd, state)
|
|
153
|
+
# elif state.device == ReplState.A:
|
|
154
|
+
# if state.app_app:
|
|
155
|
+
# c_sql_tried = True
|
|
156
|
+
# cmd = f'app {cmd}'
|
|
157
|
+
# cmds.run(cmd, state)
|
|
158
|
+
# elif state.device == ReplState.L:
|
|
159
|
+
# c_sql_tried = True
|
|
160
|
+
# cmd = f'audit {cmd}'
|
|
161
|
+
# cmds.run(cmd, state)
|
|
162
|
+
# elif state.sts:
|
|
163
|
+
# c_sql_tried = True
|
|
164
|
+
# cmd = f'cql {cmd}'
|
|
165
|
+
# cmds.run(cmd, state)
|
|
166
|
+
|
|
167
|
+
# if not c_sql_tried:
|
|
168
|
+
# log2(f'* Invalid command: {cmd}')
|
|
169
|
+
# log2()
|
|
170
|
+
# lines = [c.help(state) for c in cmd_list if c.help(state)]
|
|
171
|
+
# log2(lines_to_tabular(lines, separator='\t'))
|
|
169
172
|
except EOFError: # Handle Ctrl+D (EOF) for graceful exit
|
|
170
173
|
break
|
|
171
174
|
except Exception as e:
|
|
@@ -183,6 +186,34 @@ def enter_repl(state: ReplState):
|
|
|
183
186
|
if cmd and (state.device != ReplState.L or Config().get('audit.log-audit-queries', False)):
|
|
184
187
|
executor.submit(audit_log, cmd, state)
|
|
185
188
|
|
|
189
|
+
def try_device_default_action(state: ReplState, cmds: Command, cmd_list: list[Command]):
|
|
190
|
+
c_sql_tried = False
|
|
191
|
+
if state.device == ReplState.P:
|
|
192
|
+
pg = PostgresSession(state.namespace, state.pg_path)
|
|
193
|
+
if pg.db:
|
|
194
|
+
c_sql_tried = True
|
|
195
|
+
cmd = f'pg {cmd}'
|
|
196
|
+
cmds.run(cmd, state)
|
|
197
|
+
elif state.device == ReplState.A:
|
|
198
|
+
if state.app_app:
|
|
199
|
+
c_sql_tried = True
|
|
200
|
+
cmd = f'app {cmd}'
|
|
201
|
+
cmds.run(cmd, state)
|
|
202
|
+
elif state.device == ReplState.L:
|
|
203
|
+
c_sql_tried = True
|
|
204
|
+
cmd = f'audit {cmd}'
|
|
205
|
+
cmds.run(cmd, state)
|
|
206
|
+
elif state.sts:
|
|
207
|
+
c_sql_tried = True
|
|
208
|
+
cmd = f'cql {cmd}'
|
|
209
|
+
cmds.run(cmd, state)
|
|
210
|
+
|
|
211
|
+
if not c_sql_tried:
|
|
212
|
+
log2(f'* Invalid command: {cmd}')
|
|
213
|
+
log2()
|
|
214
|
+
lines = [c.help(state) for c in cmd_list if c.help(state)]
|
|
215
|
+
log2(lines_to_tabular(lines, separator='\t'))
|
|
216
|
+
|
|
186
217
|
def audit_log(cmd: str, state: ReplState):
|
|
187
218
|
payload = {
|
|
188
219
|
'cluster': state.namespace if state.namespace else 'NA',
|
|
@@ -11,7 +11,7 @@ __all__ = [
|
|
|
11
11
|
"SqlCompleter",
|
|
12
12
|
]
|
|
13
13
|
|
|
14
|
-
DML_COMPLETER = TermCompleter(['select', 'insert', 'delete', 'update', 'alter'])
|
|
14
|
+
DML_COMPLETER = TermCompleter(['select', 'insert', 'delete', 'update', 'alter', 'describe'])
|
|
15
15
|
|
|
16
16
|
def default_columns(tables: list[str]):
|
|
17
17
|
return 'id,x.,y.,z.'.split(',')
|
|
@@ -98,4 +98,5 @@ class SqlCompleter(Completer):
|
|
|
98
98
|
'select': SqlCompleter(table_names, 'select', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
99
99
|
'update': SqlCompleter(table_names, 'update', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
100
100
|
'alter': SqlCompleter(table_names, 'alter', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
101
|
+
'describe': SqlCompleter(table_names, 'describe', columns=columns, partition_columns=partition_columns, table_props=table_props, variant=variant),
|
|
101
102
|
}
|
|
@@ -321,7 +321,8 @@ class SqlSpec:
|
|
|
321
321
|
'update', 'where', 'set',
|
|
322
322
|
'delete',
|
|
323
323
|
'audit',
|
|
324
|
-
'alter', 'table', 'tables', 'add', 'drop', 'with'
|
|
324
|
+
'alter', 'table', 'tables', 'add', 'drop', 'with',
|
|
325
|
+
'describe'
|
|
325
326
|
]
|
|
326
327
|
|
|
327
328
|
def spec(self):
|
|
@@ -346,11 +347,32 @@ class CqlSpec(SqlSpec):
|
|
|
346
347
|
'alter_table_with_ > name > alter_table_with_p ^ table-props',
|
|
347
348
|
'alter_table_with_p > comparison > alter_table_with_p_op ^ =',
|
|
348
349
|
'alter_table_with_p_op > name|single|num > alter_table_with_p_op ^ table-prop-values',
|
|
350
|
+
|
|
351
|
+
' > describe > describe',
|
|
352
|
+
'describe_ > table > desc_table ^ table,`tables`,keyspace,keyspaces,schema',
|
|
353
|
+
'- > tables > desc_tables',
|
|
354
|
+
'- > keyspace > desc_keyspace',
|
|
355
|
+
'- > keyspaces > desc_keyspaces',
|
|
356
|
+
'- > schema > desc_schema',
|
|
357
|
+
'desc_table_ > name > desc_table_t ^ tables',
|
|
358
|
+
'desc_table_t > name > desc_table_t ^ tables',
|
|
359
|
+
'desc_table_t_ > & > desc_table_t_bg ^ &',
|
|
360
|
+
'desc_tables_ > & > desc_tables_bg ^ &',
|
|
361
|
+
'desc_keyspace_ > name > desc_keyspace_k',
|
|
362
|
+
'desc_keyspace_k_ > & > desc_keyspace_k_bg ^ &',
|
|
363
|
+
'desc_schema_ > & > desc_schema_bg ^ &',
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
KEYWORDS = SqlSpec.KEYWORDS + [
|
|
367
|
+
'schema', 'keyspace', 'keyspaces', 'tables'
|
|
349
368
|
]
|
|
350
369
|
|
|
351
370
|
def spec(self):
|
|
352
371
|
return CqlSpec.SPEC
|
|
353
372
|
|
|
373
|
+
def keywords(self):
|
|
374
|
+
return CqlSpec.KEYWORDS
|
|
375
|
+
|
|
354
376
|
class AthenaSpec(SqlSpec):
|
|
355
377
|
SPEC = SqlSpec.SPEC + [
|
|
356
378
|
'alter_table_t_ > add > alter_table_add ^ add partition,drop partition',
|
|
@@ -362,6 +384,11 @@ class AthenaSpec(SqlSpec):
|
|
|
362
384
|
'alter_partition_lp_a_op > single > alter_partition_lp_a_op_v ^ single',
|
|
363
385
|
'alter_partition_lp_a_op_v > , > alter_partition_lp_sc ^ single',
|
|
364
386
|
'alter_partition_lp_sc > name|) > alter_partition_lp_a ^ partition-columns',
|
|
387
|
+
|
|
388
|
+
' > describe > describe',
|
|
389
|
+
'describe_ > name > desc_t ^ tables',
|
|
390
|
+
'desc_t > name > desc_t ^ tables',
|
|
391
|
+
'desc_t_ > name > desc_t_',
|
|
365
392
|
]
|
|
366
393
|
|
|
367
394
|
KEYWORDS = SqlSpec.KEYWORDS + [
|
|
@@ -83,6 +83,7 @@ adam/commands/watch.py
|
|
|
83
83
|
adam/commands/audit/__init__.py
|
|
84
84
|
adam/commands/audit/audit.py
|
|
85
85
|
adam/commands/audit/audit_repair_tables.py
|
|
86
|
+
adam/commands/audit/audit_table_completer.py
|
|
86
87
|
adam/commands/cql/__init__.py
|
|
87
88
|
adam/commands/cql/cql_completions.py
|
|
88
89
|
adam/commands/cql/cql_table_completer.py
|
kaqing-2.0.99/adam/version.py
DELETED
|
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
|