Verify that ASSERT operator works. Disable fetch for this testcase. @throws Exception
()
| 132 | * @throws Exception |
| 133 | */ |
| 134 | @Test |
| 135 | public void testNegativeWithoutFetch() throws Exception { |
| 136 | PigServer pigServer = new PigServer(Util.getLocalTestMode()); |
| 137 | Data data = resetData(pigServer); |
| 138 | |
| 139 | data.set("foo", |
| 140 | tuple(1), |
| 141 | tuple(2), |
| 142 | tuple(3) |
| 143 | ); |
| 144 | |
| 145 | pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage() AS (i:int);"); |
| 146 | pigServer.registerQuery("ASSERT A BY i > 1 , 'i should be greater than 1';"); |
| 147 | |
| 148 | try { |
| 149 | pigServer.openIterator("A"); |
| 150 | } catch (FrontendException fe) { |
| 151 | if (pigServer.getPigContext().getExecType().toString().startsWith("TEZ") |
| 152 | || pigServer.getPigContext().getExecType().toString().startsWith("SPARK")) { |
| 153 | Assert.assertTrue(fe.getCause().getMessage().contains( |
| 154 | "Assertion violated: i should be greater than 1")); |
| 155 | } else { |
| 156 | Assert.assertTrue(fe.getCause().getMessage().contains( |
| 157 | "Job terminated with anomalous status FAILED")); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Verify that alias is not assignable to the ASSERT operator |
nothing calls this directly
no test coverage detected