Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add support to add and show (create table) extra hive table properties issue 954 #1176

Open
wants to merge 1 commit into
base: master
from

Conversation

@ankitdixit
Copy link
Member

commented Jul 25, 2019

Need help in ShowQueriesRewrite, please help me converting a map to an expression

@cla-bot cla-bot bot added the cla-signed label Jul 25, 2019

@ankitdixit ankitdixit changed the title [WIP] intial commit [WIP] Add support to add and show (create table) extra hive table properties issue 954 Jul 25, 2019

@ankitdixit

This comment has been minimized.

Copy link
Member Author

commented Jul 25, 2019

@ankitdixit

This comment has been minimized.

Copy link
Member Author

commented Jul 25, 2019

Working on adding and showing properties via showCreateTable, will add merge validation post that

@@ -411,6 +411,10 @@ private static Expression toExpression(Object value)
.collect(toList()));
}

if (value instanceof Map) {
//TODO: How to convert map to an expression here

This comment has been minimized.

Copy link
@ankitdixit

ankitdixit Jul 25, 2019

Author Member

There does not seem to exist a map construct which can directly be converted to expression, please suggest what to do here

This comment has been minimized.

Copy link
@dain

dain Aug 1, 2019

Member

I think invoking map_from_entries is the cleanest.

if (value instanceof Map) {
    Map<?, ?> map = (Map<?, ?>) value;
    return new FunctionCall(QualifiedName.of("map_from_entries"), ImmutableList.of(new ArrayConstructor(map.entrySet().stream()
            .map(entry -> new Row(asList(toExpression(entry.getKey()), toExpression(entry.getValue()))))
            .collect(toList()))));
}

This comment has been minimized.

Copy link
@findepi

findepi Aug 2, 2019

Member

toImmutableList 🙂

@dain dain assigned dain and unassigned dain Jul 27, 2019

@dain
Copy link
Member

left a comment

Oops, I reviewed this like a week ago and forgot to post the answer to the above question. Sorry.

When this is ready for a final review, remove the WIP label and assign it back to me.

@@ -819,6 +828,12 @@ public void createTable(ConnectorSession session, ConnectorTableMetadata tableMe
tableProperties.put(CSV_SEPARATOR_KEY, separator.toString());
});

//Extra properties

This comment has been minimized.

Copy link
@dain

dain Aug 1, 2019

Member

nit: add a space after the //

@@ -411,6 +411,10 @@ private static Expression toExpression(Object value)
.collect(toList()));
}

if (value instanceof Map) {
//TODO: How to convert map to an expression here

This comment has been minimized.

Copy link
@dain

dain Aug 1, 2019

Member

I think invoking map_from_entries is the cleanest.

if (value instanceof Map) {
    Map<?, ?> map = (Map<?, ?>) value;
    return new FunctionCall(QualifiedName.of("map_from_entries"), ImmutableList.of(new ArrayConstructor(map.entrySet().stream()
            .map(entry -> new Row(asList(toExpression(entry.getKey()), toExpression(entry.getValue()))))
            .collect(toList()))));
}

@dain dain added the WIP label Aug 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.