Skip to content

Instantly share code, notes, and snippets.

@okdtsk
Last active January 17, 2018 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okdtsk/ac861d2ce818179e953b to your computer and use it in GitHub Desktop.
Save okdtsk/ac861d2ce818179e953b to your computer and use it in GitHub Desktop.
thrift --gen go ./hive-src/metastore/if/hive_metastore.thriftについて

apache-hive-1.1.0-src/metastore/if/hive_metastore.thrift このThriftファイル内の以下の定義に対して--gen goではErrorとなる。

// this object holds all the information about skewed table
struct SkewedInfo {
  1: list<string> skewedColNames, // skewed column names
  2: list<list<string>> skewedColValues, //skewed values
  3: map<list<string>, string> skewedColValueLocationMaps, //skewed value to location mappings
}

Error messageは次の通り。

Error: Cannot produce a valid type for a Go map key: []string - aborting.

つまり、GolangではMapのkeyに[]stringをとれませんよーということ。


理由はこちら。 http://golang.org/ref/spec#Map_types

The comparison operators == and != must be fully defined for operands of the key type; thus the key type must not be a function, map, or slice. If the key type is an interface type, these comparison operators must be defined for the dynamic key values; failure will cause a run-time panic.


参考JIRA ticket. https://issues.apache.org/jira/browse/THRIFT-2063

結局はhive_metastore.thriftの対象の構造を変更するか、上記ticketでthrift golangの変換をうまくやってもらうしかないのだろうか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment