Database
The Database module provides functions to manage database connections and access schema and table information.
Modify Database Connections
This function allows you to modify existing database connections or add new ones.
public ModifyDBConnectionResponse modifyConnections(ModifyDBConnectionRequest params)
throws IOException;
Example: Adding a Salesforce Connection
// Create a new Salesforce connection
DBConnection salesforceConnection = new DBConnection();
salesforceConnection.setHost("login.salesforce.com");
salesforceConnection.setUsername("<sf username>");
salesforceConnection.setPassword("<sf password>");
salesforceConnection.setDbType("sfdc");
salesforceConnection.setClientId("<client id>");
salesforceConnection.setClientSecret("<client secret>");
salesforceConnection.setDbAlias("<alias db>");
// Create request to add the connection
ModifyDBConnectionRequest request = new ModifyDBConnectionRequest();
request.setUpdated(Arrays.asList(salesforceConnection));
request.setUserId("");
request.setOwnerUserId("");
// Add the connection
ModifyDBConnectionResponse response = database.modifyConnections(request);
Parameters:
-
params
(required): An object containing the modify database connection request parameters.updated
(optional): A List ofDBConnection
objects representing the updated database connections.removed
(optional): A List of strings representing the keys of the database connections to be removed.validateBeforeSave
(optional): A boolean value indicating whether to validate the changes before saving.userId
(optional): The ID of the user performing the modification.defaultDbConnectionKey
(optional): A string representing the key of the default database connection.ownerUserId
(optional): The ID of the owner user for the connection.
Returns:
A ModifyDBConnectionResponse
object containing the updated connectors and diagnostics.
The ModifyDBConnectionResponse
object represents the response of the "modify database connection" operation and contains the following fields:
-
connectors
(optional): A List ofDBConnection
objects representing the updated database connectors as a result of the operation. EachDBConnection
object may contain the following fields:key
(optional): A string representing the unique key or identifier of the database connection.dbType
(required): A string representing the type of the database (e.g., "sfdc" for Salesforce, "postgresql", "mysql").description
(optional): A string representing a description or additional information about the database connection.accountName
(optional): A string representing the account name associated with the database connection.username
(optional): A string representing the username used to connect to the database.password
(optional): A string representing the password used to authenticate the database connection.database
(optional): A string representing the name of the specific database to connect to.warehouse
(optional): A string representing the warehouse for the database connection.role
(optional): A string representing the role associated with the database connection.path
(optional): A string representing the path to the database.host
(optional): A string representing the host of the database connection (e.g., "login.salesforce.com").clientId
(optional): A string representing the OAuth client ID (required for Salesforce connections).clientSecret
(optional): A string representing the OAuth client secret (required for Salesforce connections).port
(optional): An integer representing the port number of the database connection.parameters
(optional): An object containing additional parameters related to the database connection.sampleColValues
(optional): A boolean value indicating whether to sample column values (default: true).push
(optional): A boolean value indicating whether this is a push-based connection (default: false).dbContentFilters
(optional): A List ofDBContentFilter
objects representing the content filters applied to the database connection.embeddingModel
(optional): A string representing the embedding model to use (e.g., "text-embedding-ada-002").alwaysIncludeTables
(optional): A List ofTableName
objects representing tables to always include.alias
(optional): A string representing an alias for the connection.dbAccessPolicy
(optional): ADBAccessPolicy
object representing access policies for the connection.hostAlias
(optional): A string representing an alias for the host.userAlias
(optional): A string representing an alias for the user.dbAlias
(optional): A string representing an alias for the database (e.g., "test_sf_db_2").clientEmail
(optional): A string representing the client email for service account authentication.contentFilters
(optional): A List ofSearchContext
objects for content filtering.sampleFilters
(optional): A List ofSearchContext
objects for sample filtering.enableMultiDbConnection
(optional): A boolean indicating whether to enable multi-database connections (default: false).defaultDatabase
(optional): A string representing the default database name.
-
diagnostics
(optional): A string representing the diagnostics information of the database connections. -
defaultDbConnectionKey
(optional): A string representing the key of the default database connection. -
connectorStatus
(optional): A map of strings toDBConnectionIndexingStatus
objects representing the status of the database connectors. EachDBConnectionIndexingStatus
object may contain the following fields:status
(optional): A string representing the status of the database connection.schemaStatus
(optional): A map of strings toSchemaIndexingStatus
objects representing the status of the schema indexing. EachSchemaIndexingStatus
object may contain the following fields:nPendingIndexingTables
(required): An integer representing the number of tables pending indexing.nTotalTables
(required): An integer representing the total number of tables.status
(required): A string representing the status of the schema indexing.
Get Database Connections
This function allows you to retrieve the list of current database connections.
public GetDBConnectionResponse getConnections(GetDBConnectionRequest params)
throws IOException;
Parameters:
params
(optional): An object containing the get database connection request parameters.
Returns:
A GetDBConnectionResponse
object containing the list of database connections and diagnostics.
The GetDBConnectionResponse
object represents the response of the "get database connections" operation and contains the following fields:
-
connectors
(optional): An array ofDBConnection
objects representing the list of database connectors retrieved from the server. EachDBConnection
object may contain the following fields:key
(required): A string representing the unique key or identifier of the database connection.dbType
(required): A string representing the type of the database (e.g., MySQL, PostgreSQL).description
(optional): A string representing a description or additional information about the database connection.accountName
(optional): A string representing the account name associated with the database connection.username
(optional): A string representing the username used to connect to the database.password
(optional): A string representing the password used to authenticate the database connection.database
(optional): A string representing the name of the specific database to connect to.warehouse
(optional): A string representing the warehouse for the database connection.role
(optional): A string representing the role associated with the database connection.path
(optional): A string representing the path to the database.host
(optional): A string representing the host of the database connection.port
(optional): An integer representing the port number of the database connection.parameters
(optional): An object containing additional parameters related to the database connection.sampleColValues
(optional): A boolean value indicating whether to sample column values.dbContentFilters
(optional): An array ofDBContentFilter
objects representing the content filters applied to the database connection.
-
diagnostics
(optional): An array of strings representing the diagnostics information of the database connections. -
defaultDbConnectionKey
(optional): A string representing the key of the default database connection. -
connectorStatus
(optional): A map of strings toDBConnectionIndexingStatus
objects representing the status of the database connectors. EachDBConnectionIndexingStatus
object may contain the following fields:status
(required): A string representing the status of the database connection.schemaStatus
(optional): A map of strings toSchemaIndexingStatus
objects representing the status of the schema indexing. EachSchemaIndexingStatus
object may contain the following fields:pendingIndexingTables
(required): An integer representing the number of tables pending indexing.totalTables
(required): An integer representing the total number of tables.status
(required): A string representing the status of the schema indexing.
Get Default Connection
This function allows you to get the default database connection for subsequent API calls.
public String getDefaultConnection();
Activate Connection
This function allows you to activate a specific database connection for subsequent API calls.
public ModifyDBConnectionResponse activateConnection(String key)
throws IOException;
Parameters:
key
(required): The key of the database connection to activate.
Get Catalogs
This function allows you to fetch information about catalogs, schemas, and tables.
public GetCatalogResponse getCatalogs(GetCatalogRequest params)
throws IOException;
Parameters:
params
(optional): An object containing the get catalogs request parameters.
Returns:
A GetCatalogResponse
object containing the list of catalogs and associated schema and table information.
The GetCatalogResponse
object represents the response of the "get catalogs" operation and contains the following fields:
catalogs
(optional): An array ofCatalog
objects representing the list of catalogs retrieved from the server. EachCatalog
object may contain the following fields:name
(required): A string representing the name of the catalog.schemas
(optional): An array ofSchema
objects representing the list of schemas associated with the catalog. EachSchema
object may contain the following fields:name
(required): ASchemaName
object representing the name of the schema.tables
(optional): An array ofTable
objects representing the list of tables in the schema. EachTable
object may contain the following fields:name
(required): ATableName
object representing the name of the table.columns
(optional): An array ofColumn
objects representing the list of columns in the table. EachColumn
object may contain the following fields:name
(required): A string representing the name of the column.type
(required): A string representing the data type of the column.comment
(optional): A string representing any comment or description associated with the column.sampleValues
(optional): AColumnSampleValues
object representing sample values for the column. EachColumnSampleValues
object may contain the following fields:values
(optional): A map of strings to integers representing sample values for the column, along with their respective counts.ndv
(optional): An integer representing the number of distinct values in the column.
Get Default Connection
This function allows you to get the default database connection for subsequent API calls.
public String getDefaultConnection();
Update Schema Description
This function allows you to update the description of a schema.
public ModifyDBConnectionResponse updateSchemaDescription(UpdateSchemaDescriptionRequest params)
throws IOException;
Parameters:
-
params
(required): An object containing the update schema description request parameters.schemaName
(required): ASchemaName
object representing the name of the schema.description
(required): ASchemaDescription
object representing the description of the schema.
Returns:
A ModifyDBConnectionResponse
object containing the updated schema description.
Update Table Description
This function allows you to update the description of a table.
public ModifyDBConnectionResponse updateTableDescription(UpdateTableDescriptionRequest params)
throws IOException;
Parameters:
-
params
(required): An object containing the update table description request parameters.tableName
(required): ATableName
object representing the name of the table.description
(required): A string representing the description of the table.
Returns:
A ModifyDBConnectionResponse
object containing the updated table description.
Update Column Description
This function allows you to update the description of a column.
public ModifyDBConnectionResponse updateColumnDescription(UpdateColumnDescriptionRequest params)
throws IOException;
Parameters:
-
params
(required): An object containing the update column description request parameters.colDescriptions
(required): An array ofTableToColumnDescription
objects representing the column descriptions to update. EachTableToColumnDescription
object may contain the following fields:tableName
(required): ATableName
object representing the name of the table.columnDescriptions
(required): An array ofColumnDescription
objects representing the descriptions of the columns. EachColumnDescription
object may contain the following fields:columnName
(required): A string representing the name of the column.description
(required): A string representing the description of the column.