@brief Get the column information of this table. @param name The URI or the name of the ddf. @param namespace The namespace. @return The column information. @throws DDFException
(String name, String namespace)
| 60 | * @throws DDFException |
| 61 | */ |
| 62 | private SqlResult describeTable(String name, String namespace) |
| 63 | throws DDFException { |
| 64 | DDF ddf = null; |
| 65 | try { |
| 66 | ddf = this.getManager().getOrRestoreDDFUri(name); |
| 67 | } catch (Exception e) { |
| 68 | if (null == namespace) { |
| 69 | throw new DDFException("ERROR: there is no ddf " + name); |
| 70 | } |
| 71 | try { |
| 72 | mLog.info("trying to restore " + "ddf://" + namespace + "/" + name); |
| 73 | ddf = this.getManager().getOrRestoreDDFUri("ddf://" + namespace + "/" + name); |
| 74 | } catch (Exception e2) { |
| 75 | throw new DDFException("ERROR: there is no ddf " + name); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | int colSize = ddf.getNumColumns(); |
| 80 | List<String> ret = new ArrayList<String>(); |
| 81 | for (int colIdx = 0; colIdx < colSize; ++colIdx) { |
| 82 | Schema.Column col = ddf.getColumn(ddf.getColumnName(colIdx)); |
| 83 | ret.add(col.getName().concat("\t").concat(col.getType().toString() |
| 84 | .toLowerCase())); |
| 85 | } |
| 86 | List<Column> columnList = new ArrayList<Column>(); |
| 87 | columnList.add(new Column("column_name", Schema.ColumnType.STRING)); |
| 88 | columnList.add(new Column("value_type", Schema.ColumnType.STRING)); |
| 89 | Schema schema = new Schema("table_info", columnList); |
| 90 | return new SqlResult(schema, ret); |
| 91 | } |
| 92 | |
| 93 | public SqlResult sqlHandle(String command, |
| 94 | Integer maxRows, |
no test coverage detected