added updated_at column to show tables output (#2364)

(cherry picked from commit 9759602f94)
This commit is contained in:
pokeeffe-molecula 2022-12-14 10:15:42 -06:00 committed by Joe Friedrich
parent 75999414a7
commit b46a82ea33
3 changed files with 18 additions and 4 deletions

View file

@ -53,14 +53,20 @@ func (p *ExecutionPlanner) compileShowTablesStatement(stmt parser.Statement) (ty
},
&qualifiedRefPlanExpression{
tableName: "fb_tables",
columnName: "keys",
columnName: "updated_at",
columnIndex: 5,
dataType: parser.NewDataTypeTimestamp(),
},
&qualifiedRefPlanExpression{
tableName: "fb_tables",
columnName: "keys",
columnIndex: 6,
dataType: parser.NewDataTypeBool(),
},
&qualifiedRefPlanExpression{
tableName: "fb_tables",
columnName: "description",
columnIndex: 6,
columnIndex: 7,
dataType: parser.NewDataTypeString(),
}}

View file

@ -76,6 +76,11 @@ func (p *PlanOpFeatureBaseTables) Schema() types.Schema {
ColumnName: "created_at",
Type: parser.NewDataTypeTimestamp(),
},
&types.PlannerColumn{
RelationName: "fb_tables",
ColumnName: "updated_at",
Type: parser.NewDataTypeTimestamp(),
},
&types.PlannerColumn{
RelationName: "fb_tables",
ColumnName: "keys",
@ -112,13 +117,15 @@ var _ types.RowIterator = (*showTablesRowIter)(nil)
func (i *showTablesRowIter) Next(ctx context.Context) (types.Row, error) {
if i.rowIndex < len(i.indexInfo) {
tm := time.Unix(0, i.indexInfo[i.rowIndex].CreatedAt)
createdAt := time.Unix(0, i.indexInfo[i.rowIndex].CreatedAt)
updatedAt := time.Unix(0, i.indexInfo[i.rowIndex].UpdatedAt)
row := []interface{}{
i.indexInfo[i.rowIndex].Name,
i.indexInfo[i.rowIndex].Name,
i.indexInfo[i.rowIndex].Owner,
i.indexInfo[i.rowIndex].LastUpdateUser,
tm.Format(time.RFC3339),
createdAt.Format(time.RFC3339),
updatedAt.Format(time.RFC3339),
i.indexInfo[i.rowIndex].Options.Keys,
i.indexInfo[i.rowIndex].Options.Description,
}

View file

@ -174,6 +174,7 @@ func TestPlanner_Show(t *testing.T) {
wireQueryFieldString("owner"),
wireQueryFieldString("updated_by"),
wireQueryFieldTimestamp("created_at"),
wireQueryFieldTimestamp("updated_at"),
wireQueryFieldBool("keys"),
wireQueryFieldString("description"),
}, columns); diff != "" {