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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
node_modules
.DS_Store
release
TeradataClient/target
2 changes: 1 addition & 1 deletion TeradataClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>com.teradata.jdbc</groupId>
<artifactId>terajdbc</artifactId>
<version>17.20.00.12</version>
<version>20.00.00.46</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
Expand Down
7 changes: 7 additions & 0 deletions constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ const ERROR_MESSAGE = {
aborted: 'Query execution was aborted',
};

const TABLE_KIND = {
regularTable: 'T',
noPiTable: 'O',
view: 'V',
};

module.exports = {
ERROR_MESSAGE,
TABLE_KIND,
};
Binary file modified reverse_engineering/addons/TeradataClient.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const connectionHelper = require('./helpers/connectionHelper');
const indexHelper = require('./helpers/indexHelper');
const udtHelper = require('./helpers/udtHelper');
const { prepareError } = require('./helpers/prepareError');
const { TABLE_KIND } = require('../constants/constants');

const connect = async (connectionInfo, sshService, logger) => {
return await connectionHelper.connect(connectionInfo, sshService, logger);
Expand Down Expand Up @@ -62,10 +63,10 @@ const getDbCollectionsNames = async (connectionInfo, logger, callback, app) => {
const instance = connectionHelper.createInstance(connection, _);

log.info('Get table and database names');
const tableNames = await instance.getDatabasesWithTableNames('T');
const tableNames = await instance.getDatabasesWithTableNames([TABLE_KIND.regularTable, TABLE_KIND.noPiTable]);

log.info('Get views and database names');
const viewNames = getViewNames(await instance.getDatabasesWithTableNames('V'));
const viewNames = getViewNames(await instance.getDatabasesWithTableNames(TABLE_KIND.view));

const allDatabaseNames = [...Object.keys(tableNames), ...Object.keys(viewNames)];

Expand Down
5 changes: 4 additions & 1 deletion reverse_engineering/helpers/connectionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ const getIndexType = index => {

const filterUdt = object => object.Kind === 'U';

const excludeSystemUdt = type => !SYSTEM_UDT.has(type['Table/View/Macro Dictionary Name']);
const excludeSystemUdt = type => {
const creator = type['Creator SQL Name'].trim();
return !SYSTEM_UDT.has(type['Table/View/Macro Dictionary Name']) && creator !== 'DBC' && creator !== 'SYSUDTLIB';
};

module.exports = {
connect,
Expand Down
11 changes: 10 additions & 1 deletion reverse_engineering/helpers/queryHelper.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const cleanUpCommand = (command = '') => command.replaceAll(/\s+/g, ' ');

const getTableKindClause = ({ tableType }) => {
if (Array.isArray(tableType)) {
const types = tableType.map(type => `'${type}'`).join(',');
return `IN (${types})`;
}

return `= '${tableType}'`;
};

const getDatabaseAndTableNames = ({ tableType, systemDatabases }) => {
const command = `SELECT DatabaseName, TableName
FROM DBC.TablesV
WHERE TableKind = '${tableType}'
WHERE TableKind ${getTableKindClause({ tableType })}
AND DatabaseName NOT IN (${systemDatabases.map(name => `'${name}'`).join(', ')})
ORDER BY DatabaseName, TableName;`;

Expand Down