databricks-cli
Version:
A CLI tool for quick Databricks tasks
31 lines (30 loc) • 1.12 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.describeTable = describeTable;
const connection_1 = require("../utils/connection");
const interactive_1 = require("../utils/interactive");
async function describeTable(options) {
try {
// Get database interactively if not provided
let database = options.database;
if (!database) {
database = await (0, interactive_1.selectDatabase)();
}
let table = options.table;
if (!table) {
table = await (0, interactive_1.selectTable)(database);
}
const session = await (0, connection_1.getSharedSession)();
const query = `DESCRIBE TABLE ${database}.${table}`;
const queryOperation = await session.executeStatement(query);
const result = await queryOperation.fetchAll();
console.table(result);
}
catch (error) {
console.error("Error describing table:", error instanceof Error ? error.message : error);
process.exit(1);
}
finally {
await (0, connection_1.closeConnection)();
}
}
;