Verifies SeqScan's getTupleDesc prefixes the table name + "." to the field names @throws IOException
()
| 114 | * @throws IOException |
| 115 | */ |
| 116 | @Test public void testTupleDesc() throws IOException { |
| 117 | List<List<Integer>> tuples = new ArrayList<>(); |
| 118 | HeapFile f = SystemTestUtil.createRandomHeapFile(2, 1000, null, tuples, "test"); |
| 119 | |
| 120 | TransactionId tid = new TransactionId(); |
| 121 | String prefix = "table_alias"; |
| 122 | SeqScan scan = new SeqScan(tid, f.getId(), prefix); |
| 123 | |
| 124 | TupleDesc original = f.getTupleDesc(); |
| 125 | TupleDesc prefixed = scan.getTupleDesc(); |
| 126 | assertEquals(prefix, scan.getAlias()); |
| 127 | |
| 128 | // Sanity check the number of fields |
| 129 | assertEquals(original.numFields(), prefixed.numFields()); |
| 130 | |
| 131 | // Check each field for the appropriate tableAlias. prefix |
| 132 | for (int i = 0; i < original.numFields(); i++) { |
| 133 | assertEquals(prefix + "." + original.getFieldName(i), prefixed.getFieldName(i)); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | /** Make test compatible with older version of ant. */ |
| 138 | public static junit.framework.Test suite() { |
nothing calls this directly
no test coverage detected