@@ -2637,78 +2637,84 @@ public void testType() throws Exception {
26372637 @ Test
26382638 public void testIsType () throws Exception {
26392639 List <PipelineResult > results =
2640- firestore
2641- .pipeline ()
2642- .collection (collection .getPath ())
2643- .replaceWith (Expression .map (
2644- map (
2645- "int" , 1 ,
2646- "float" , 1.1 ,
2647- "str" , "a string" ,
2648- "bool" , true ,
2649- "null" , null ,
2650- "geoPoint" , new GeoPoint (0.1 , 0.2 ),
2651- "timestamp" , Timestamp .ofTimeSecondsAndNanos (123456 , 0 ),
2652- "bytes" , com .google .cloud .firestore .Blob .fromBytes (new byte []{1 , 2 ,3 }),
2653- "docRef" , collection .document ("bar" ),
2654- "vector" , vector (new double [] {1.0 , 2.0 , 3.0 }),
2655- "map" , Expression .map (map ("numberK" , 1 , "stringK" , "a string" )),
2656- "array" , array (1 , 2 , true )
2657- )
2658- ))
2659- .select (
2660- Expression .isType ("int" , Type .INT64 ).as ("isInt64" ),
2661- Expression .isType ("int" , Type .NUMBER ).as ("isInt64IsNumber" ),
2662- Expression .isType ("int" , Type .DECIMAL128 ).as ("isInt64IsDecimal128" ),
2663- Expression .isType ("float" , Type .FLOAT64 ).as ("isFloat64" ),
2664- Expression .isType ("float" , Type .NUMBER ).as ("isFloat64IsNumber" ),
2665- Expression .isType ("float" , Type .DECIMAL128 ).as ("isFloat64IsDecimal128" ),
2666- Expression .isType ("str" , Type .STRING ).as ("isStr" ),
2667- Expression .isType ("str" , Type .INT64 ).as ("isStrNum" ),
2668- Expression .isType ("int" , Type .STRING ).as ("isNumStr" ),
2669- Expression .isType ("bool" , Type .BOOLEAN ).as ("isBool" ),
2670- Expression .isType ("null" , Type .NULL ).as ("isNull" ),
2671- Expression .isType ("geoPoint" , Type .GEO_POINT ).as ("isGeoPoint" ),
2672- Expression .isType ("timestamp" , Type .TIMESTAMP ).as ("isTimestamp" ),
2673- Expression .isType ("bytes" , Type .BYTES ).as ("isBytes" ),
2674- Expression .isType ("docRef" , Type .REFERENCE ).as ("isDocRef" ),
2675- Expression .isType ("vector" , Type .VECTOR ).as ("isVector" ),
2676- Expression .isType ("map" , Type .MAP ).as ("isMap" ),
2677- Expression .isType ("array" , Type .ARRAY ).as ("isArray" ),
2678-
2679- Expression .isType (constant (1 ), Type .INT64 ).as ("exprIsInt64" ),
2680- field ("int" ).isType (Type .INT64 ).as ("staticIsInt64" )
2681- )
2682- .limit (1 )
2683- .execute ()
2684- .get ()
2685- .getResults ();
2686- assertThat (data (results ))
2687- .containsExactly (
2640+ firestore
2641+ .pipeline ()
2642+ .collection (collection .getPath ())
2643+ .replaceWith (
2644+ Expression .map (
26882645 map (
2689- "isInt64" , true ,
2690- "isInt64IsNumber" , true ,
2691- "isInt64IsDecimal128" , false ,
2692- "isFloat64" , true ,
2693- "isFloat64IsNumber" , true ,
2694- "isFloat64IsDecimal128" , false ,
2695- "isStr" , true ,
2696- "isStrNum" , false ,
2697- "isNumStr" , false ,
2698- "isBool" , true ,
2699- "isNull" , true ,
2700- "isGeoPoint" , true ,
2701- "isTimestamp" , true ,
2702- "isBytes" , true ,
2703- "isDocRef" , true ,
2704- "isVector" , true ,
2705- "isMap" , true ,
2706- "isArray" , true ,
2707-
2708- "exprIsInt64" , true ,
2709- "staticIsInt64" , true
2710- )
2711- );
2646+ "int" ,
2647+ 1 ,
2648+ "float" ,
2649+ 1.1 ,
2650+ "str" ,
2651+ "a string" ,
2652+ "bool" ,
2653+ true ,
2654+ "null" ,
2655+ null ,
2656+ "geoPoint" ,
2657+ new GeoPoint (0.1 , 0.2 ),
2658+ "timestamp" ,
2659+ Timestamp .ofTimeSecondsAndNanos (123456 , 0 ),
2660+ "bytes" ,
2661+ com .google .cloud .firestore .Blob .fromBytes (new byte [] {1 , 2 , 3 }),
2662+ "docRef" ,
2663+ collection .document ("bar" ),
2664+ "vector" ,
2665+ vector (new double [] {1.0 , 2.0 , 3.0 }),
2666+ "map" ,
2667+ Expression .map (map ("numberK" , 1 , "stringK" , "a string" )),
2668+ "array" ,
2669+ array (1 , 2 , true ))))
2670+ .select (
2671+ Expression .isType ("int" , Type .INT64 ).as ("isInt64" ),
2672+ Expression .isType ("int" , Type .NUMBER ).as ("isInt64IsNumber" ),
2673+ Expression .isType ("int" , Type .DECIMAL128 ).as ("isInt64IsDecimal128" ),
2674+ Expression .isType ("float" , Type .FLOAT64 ).as ("isFloat64" ),
2675+ Expression .isType ("float" , Type .NUMBER ).as ("isFloat64IsNumber" ),
2676+ Expression .isType ("float" , Type .DECIMAL128 ).as ("isFloat64IsDecimal128" ),
2677+ Expression .isType ("str" , Type .STRING ).as ("isStr" ),
2678+ Expression .isType ("str" , Type .INT64 ).as ("isStrNum" ),
2679+ Expression .isType ("int" , Type .STRING ).as ("isNumStr" ),
2680+ Expression .isType ("bool" , Type .BOOLEAN ).as ("isBool" ),
2681+ Expression .isType ("null" , Type .NULL ).as ("isNull" ),
2682+ Expression .isType ("geoPoint" , Type .GEO_POINT ).as ("isGeoPoint" ),
2683+ Expression .isType ("timestamp" , Type .TIMESTAMP ).as ("isTimestamp" ),
2684+ Expression .isType ("bytes" , Type .BYTES ).as ("isBytes" ),
2685+ Expression .isType ("docRef" , Type .REFERENCE ).as ("isDocRef" ),
2686+ Expression .isType ("vector" , Type .VECTOR ).as ("isVector" ),
2687+ Expression .isType ("map" , Type .MAP ).as ("isMap" ),
2688+ Expression .isType ("array" , Type .ARRAY ).as ("isArray" ),
2689+ Expression .isType (constant (1 ), Type .INT64 ).as ("exprIsInt64" ),
2690+ field ("int" ).isType (Type .INT64 ).as ("staticIsInt64" ))
2691+ .limit (1 )
2692+ .execute ()
2693+ .get ()
2694+ .getResults ();
2695+ assertThat (data (results ))
2696+ .containsExactly (
2697+ map (
2698+ "isInt64" , true ,
2699+ "isInt64IsNumber" , true ,
2700+ "isInt64IsDecimal128" , false ,
2701+ "isFloat64" , true ,
2702+ "isFloat64IsNumber" , true ,
2703+ "isFloat64IsDecimal128" , false ,
2704+ "isStr" , true ,
2705+ "isStrNum" , false ,
2706+ "isNumStr" , false ,
2707+ "isBool" , true ,
2708+ "isNull" , true ,
2709+ "isGeoPoint" , true ,
2710+ "isTimestamp" , true ,
2711+ "isBytes" , true ,
2712+ "isDocRef" , true ,
2713+ "isVector" , true ,
2714+ "isMap" , true ,
2715+ "isArray" , true ,
2716+ "exprIsInt64" , true ,
2717+ "staticIsInt64" , true ));
27122718 }
27132719
27142720 @ Test
0 commit comments