Skip to content

Commit 283c46f

Browse files
fix: removed braces for alias (#52)
* removed braces for alias * updated test cases * bumped up package.json versions
1 parent 967b180 commit 283c46f

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

meerkat-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devrev/meerkat-core",
3-
"version": "0.0.60",
3+
"version": "0.0.61",
44
"dependencies": {
55
"@swc/helpers": "~0.5.0"
66
},

meerkat-core/src/cube-measure-transformer/cube-measure-transformer.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ describe('cubeMeasureToSQLSelectString', () => {
3131
it('should construct a SQL select string with COUNT(*) when provided with correct measure', () => {
3232
const measures: Member[] = ['temp.measure1'];
3333
const result = cubeMeasureToSQLSelectString(measures, tableSchema);
34-
expect(result).toBe(`SELECT (COUNT(*)) AS temp__measure1 `);
34+
expect(result).toBe(`SELECT COUNT(*) AS temp__measure1 `);
3535
});
3636

3737
it('should construct a SQL select string with SUM(total) when provided with correct measure', () => {
3838
const measures: Member[] = ['temp.measure2'];
3939
const result = cubeMeasureToSQLSelectString(measures, tableSchema);
40-
expect(result).toBe(`SELECT (SUM(total)) AS temp__measure2 `);
40+
expect(result).toBe(`SELECT SUM(total) AS temp__measure2 `);
4141
});
4242

4343
it('should substitute "*" for all columns in the cube', () => {
@@ -56,7 +56,7 @@ describe('cubeMeasureToSQLSelectString', () => {
5656
sqlToReplace
5757
);
5858
expect(result).toBe(
59-
`SELECT (COUNT(*)) AS temp__measure1 , (SUM(total)) AS temp__measure2 FROM my_table`
59+
`SELECT COUNT(*) AS temp__measure1 , SUM(total) AS temp__measure2 FROM my_table`
6060
);
6161
});
6262

@@ -70,7 +70,7 @@ describe('cubeMeasureToSQLSelectString', () => {
7070
sqlToReplace
7171
);
7272
expect(result).toBe(
73-
`SELECT (COUNT(*)) AS temp__measure1 , (SUM(total)) AS temp__measure2 FROM (SELECT * FROM TABLE_1)`
73+
`SELECT COUNT(*) AS temp__measure1 , SUM(total) AS temp__measure2 FROM (SELECT * FROM TABLE_1)`
7474
);
7575
});
7676

@@ -85,7 +85,7 @@ describe('cubeMeasureToSQLSelectString', () => {
8585
sqlToReplace
8686
);
8787
expect(result).toBe(
88-
`SELECT (COUNT(*)) AS temp__measure1 , (SUM(total)) AS temp__measure2 , (dimension1) AS temp__dimension1, (DATE_TRUNC('month', order_date)) AS temp__dimension2 FROM (SELECT * FROM TABLE_1)`
88+
`SELECT COUNT(*) AS temp__measure1 , SUM(total) AS temp__measure2 , dimension1 AS temp__dimension1, DATE_TRUNC('month', order_date) AS temp__dimension2 FROM (SELECT * FROM TABLE_1)`
8989
);
9090
});
9191
});

meerkat-core/src/cube-measure-transformer/cube-measure-transformer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const cubeMeasureToSQLSelectString = (
2424
if (i > 0) {
2525
base += ',';
2626
}
27-
base += ` (${measureSchema.sql}) AS ${aliasKey} `;
27+
base += ` ${measureSchema.sql} AS ${aliasKey} `;
2828
}
2929
return base;
3030
};
@@ -52,7 +52,7 @@ const addDimensionToSQLProjection = (
5252
if (i > 0) {
5353
newSelectString += ',';
5454
}
55-
newSelectString += ` (${dimensionSchema.sql}) AS ${aliasKey}`;
55+
newSelectString += ` ${dimensionSchema.sql} AS ${aliasKey}`;
5656
}
5757
return newSelectString;
5858
};

meerkat-node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devrev/meerkat-node",
3-
"version": "0.0.61",
3+
"version": "0.0.62",
44
"dependencies": {
55
"@swc/helpers": "~0.5.0",
66
"@devrev/meerkat-core": "*",

meerkat-node/src/__tests__/test-data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const TABLE_SCHEMA = {
7070
export const TEST_DATA = [
7171
{
7272
testName: 'GroupBySQLInnerQuery',
73-
expectedSQL: `SELECT (SUM(order_amount)) AS orders__total_order_amount , (DATE_TRUNC('month', order_date)) AS orders__order_month FROM (select * from orders) AS orders GROUP BY orders__order_month LIMIT 1`,
73+
expectedSQL: `SELECT SUM(order_amount) AS orders__total_order_amount , DATE_TRUNC('month', order_date) AS orders__order_month FROM (select * from orders) AS orders GROUP BY orders__order_month LIMIT 1`,
7474
cubeInput: {
7575
measures: ['orders.total_order_amount'],
7676
filters: [],
@@ -86,7 +86,7 @@ export const TEST_DATA = [
8686
},
8787
{
8888
testName: 'GroupBy',
89-
expectedSQL: `SELECT (SUM(order_amount)) AS orders__total_order_amount , (customer_id) AS orders__customer_id FROM (select * from orders) AS orders GROUP BY orders__customer_id`,
89+
expectedSQL: `SELECT SUM(order_amount) AS orders__total_order_amount , customer_id AS orders__customer_id FROM (select * from orders) AS orders GROUP BY orders__customer_id`,
9090
cubeInput: {
9191
measures: ['orders.total_order_amount'],
9292
filters: [],

0 commit comments

Comments
 (0)