Skip to content

Commit

Permalink
Revert "fix how cast to boolean works to preserve null (#301)" (#304)
Browse files Browse the repository at this point in the history
This reverts commit 848b4fe.
  • Loading branch information
jgoz authored Jan 8, 2024
1 parent 8488ccd commit 3036512
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
2 changes: 1 addition & 1 deletion src/dialect/druidDialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class DruidDialect extends SQLDialect {
BOOLEAN: {
NUMBER: '($$ = 1)',
STRING: `($$ = 'true')`,
_: `CASE CAST($$ AS VARCHAR) WHEN '1' THEN TRUE WHEN 'true' THEN TRUE WHEN '0' THEN FALSE WHEN 'false' THEN FALSE END`,
_: `(CAST($$ AS VARCHAR) IN ('1','true'))`,
},
};

Expand Down
39 changes: 0 additions & 39 deletions test/simulate/simulateDruidSql.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
const { expect } = require('chai');

const plywood = require('../plywood');
const { sane } = require('../utils');

const { Expression, External, Dataset, TimeRange, $, ply, r, s$ } = plywood;

Expand Down Expand Up @@ -509,44 +508,6 @@ describe('simulate DruidSql', () => {
]);
});

it('works with boolean cast', () => {
const ex = ply()
.apply('diamonds', $('diamonds').filter($('color').in(['red', 'green', 'blue'])))
.apply(
'Tags',
$('diamonds')
.split(s$('t.tags').cast('BOOLEAN'), 'B')
.apply('count', $('diamonds').count())
.sort('$count', 'descending')
.limit(10)
.select('B', 'count'),
);

const queryPlan = ex.simulateQueryPlan({
diamonds: External.fromJS({
engine: 'druidsql',
version: '0.20.0',
source: 'diamonds',
timeAttribute: 'time',
attributes,
allowSelectQueries: true,
mode: 'raw',
}),
});

expect(queryPlan.length).to.equal(1);
expect(queryPlan[0][0].query).to.deep.equal(sane`
SELECT
CASE CAST((t.tags) AS VARCHAR) WHEN '1' THEN TRUE WHEN 'true' THEN TRUE WHEN '0' THEN FALSE WHEN 'false' THEN FALSE END AS "B",
COUNT(*) AS "count"
FROM "diamonds" AS t
WHERE "color" IN ('red','green','blue')
GROUP BY 1
ORDER BY "count" DESC
LIMIT 10
`);
});

it('works with mvFilterOnly and mvOverlap', () => {
const ex = ply()
.apply('diamonds', $('diamonds'))
Expand Down

0 comments on commit 3036512

Please sign in to comment.