@@ -961,7 +961,7 @@ describe('SQL Generation', () => {
961961
962962 ] ) ;
963963
964- it ( 'Base joins - one-one join' , async ( ) => {
964+ it ( 'one-one join' , async ( ) => {
965965 await compilers . compiler . compile ( ) ;
966966
967967 const query = new PostgresQuery ( compilers , {
@@ -980,7 +980,7 @@ describe('SQL Generation', () => {
980980 expect ( queryAndParams [ 0 ] ) . toContain ( 'LEFT JOIN card3_tbl AS "cards_c" ON "cards_b".other_id = "cards_c".id' ) ;
981981 } ) ;
982982
983- it ( 'Base joins - multiplied join' , async ( ) => {
983+ it ( 'multiplied join' , async ( ) => {
984984 await compilers . compiler . compile ( ) ;
985985
986986 const query = new PostgresQuery ( compilers , {
@@ -994,12 +994,59 @@ describe('SQL Generation', () => {
994994 timezone : 'America/Los_Angeles' ,
995995 } ) ;
996996
997- const queryAndParams = query . buildSqlAndParams ( ) ;
997+ const _queryAndParams = query . buildSqlAndParams ( ) ;
998998
999999 /* expect(queryAndParams[0]).toContain('LEFT JOIN card2_tbl AS "cards_b" ON "cards_a".other_id = "cards_b".id');
10001000 expect(queryAndParams[0]).toContain('LEFT JOIN card3_tbl AS "cards_c" ON "cards_b".other_id = "cards_c".id'); */
10011001 } ) ;
1002+
1003+ it ( 'join hint cache' , async ( ) => {
1004+ // Create a schema with a segment that uses FILTER_PARAMS
1005+ const filterParamsCompilers = /** @type Compilers */ prepareJsCompiler ( [
1006+ createCubeSchema ( {
1007+ name : 'cardsA' ,
1008+ sqlTable : 'card_tbl' ,
1009+ joins : `{
1010+ cardsB: {
1011+ sql: \`\${CUBE}.other_id = \${cardsB}.id\`,
1012+ relationship: 'one_to_one'
1013+ },
1014+ }`
1015+ } ) . replace ( `sql: \`\${CUBE}.location = 'San Francisco'\`` , `sql: \`\${FILTER_PARAMS.cardsA.location.filter('location')}\`` ) ,
1016+ createCubeSchema ( {
1017+ name : 'cardsB' ,
1018+ sqlTable : 'card2_tbl' ,
1019+ } ) ,
1020+ ] ) ;
1021+ await filterParamsCompilers . compiler . compile ( ) ;
1022+
1023+ // First query requires a join
1024+ const queryWithJoin = new PostgresQuery ( filterParamsCompilers , {
1025+ dimensions : [
1026+ 'cardsA.id' ,
1027+ 'cardsB.id' ,
1028+ ] ,
1029+ segments : [
1030+ 'cardsA.sfUsers' ,
1031+ ] ,
1032+ } ) ;
1033+ const queryAndParamsWithJoin = queryWithJoin . buildSqlAndParams ( ) ;
1034+ expect ( queryAndParamsWithJoin [ 0 ] ) . toContain ( 'LEFT JOIN card2_tbl AS "cards_b" ON "cards_a".other_id = "cards_b".id' ) ;
1035+
1036+ // Second query does not require a join and should not be impacted by the first query
1037+ const queryWithoutJoin = new PostgresQuery ( filterParamsCompilers , {
1038+ dimensions : [
1039+ 'cardsA.id' ,
1040+ ] ,
1041+ segments : [
1042+ 'cardsA.sfUsers' ,
1043+ ] ,
1044+ } ) ;
1045+ const queryAndParamsWithoutJoin = queryWithoutJoin . buildSqlAndParams ( ) ;
1046+ expect ( queryAndParamsWithoutJoin [ 0 ] ) . not . toContain ( 'JOIN' ) ;
1047+ } ) ;
10021048 } ) ;
1049+
10031050 describe ( 'Common - JS' , ( ) => {
10041051 const compilers = /** @type Compilers */ prepareJsCompiler (
10051052 createCubeSchema ( {
0 commit comments