File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
packages/cubejs-schema-compiler/src/adapter Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class ClickHouseFilter extends BaseFilter {
1616 likeIgnoreCase ( column , not , param , type ) {
1717 const p = ( ! type || type === 'contains' || type === 'ends' ) ? '%' : '' ;
1818 const s = ( ! type || type === 'contains' || type === 'starts' ) ? '%' : '' ;
19- return `lower (${ column } ) ${ not ? 'NOT' : '' } LIKE CONCAT(' ${ p } ', lower( ${ this . allocateParam ( param ) } ), ' ${ s } ' )` ;
19+ return `lowerUTF8 (${ column } ) ${ not ? 'NOT' : '' } LIKE lowerUTF8( ${ p } ${ this . allocateParam ( param ) } ${ s } )` ;
2020 }
2121
2222 castParameter ( ) {
@@ -149,6 +149,28 @@ export class ClickHouseQuery extends BaseQuery {
149149 return `${ fieldAlias } ${ direction } ` ;
150150 }
151151
152+ orderBy ( ) {
153+ //
154+ // ClickHouse orders string by bytes, so we need to use COLLATE 'en' to order by string
155+ //
156+ if ( R . isEmpty ( this . order ) ) {
157+ return '' ;
158+ }
159+
160+ const orderByString = R . pipe (
161+ R . map ( this . orderHashToString ) ,
162+ R . reject ( R . isNil ) ,
163+ R . join ( ' COLLATE \'en\'' ) ,
164+ R . join ( ', ' )
165+ ) ( this . order ) ;
166+
167+ if ( ! orderByString ) {
168+ return '' ;
169+ }
170+
171+ return ` ORDER BY ${ orderByString } ` ;
172+ }
173+
152174 groupByClause ( ) {
153175 if ( this . ungrouped ) {
154176 return '' ;
You can’t perform that action at this time.
0 commit comments