module Dag::Client::API::Database
Public Instance Methods
create_database(cluster_name, db_name)
click to toggle source
# File lib/dag/client/api/database.rb, line 11 def create_database(cluster_name, db_name) raise Dag::Client::ParameterInvalid.new('cluster_name is blank') if cluster_name.blank? raise Dag::Client::ParameterInvalid.new('db_name is blank') if db_name.blank? if db_name.length < 3 raise Dag::Client::ParameterInvalid.new("db name is too short") end if db_name.length > 63 raise Dag::Client::ParameterInvalid.new("db name is too long") end if db_name !~ /\A[a-z0-9]+\Z/ raise Dag::Client::ParameterInvalid.new("db name is invalid") end if hive_reserved_word?(db_name) raise Dag::Client::ParameterInvalid.new("db name is reserved by hive") end execute(RestParameter.new(:put, "/v1/#{cluster_name}/#{db_name}", content_type: 'application/json', cano_resource: "database")) end
database_list(cluster_name, options = {})
click to toggle source
# File lib/dag/client/api/database.rb, line 6 def database_list(cluster_name, options = {}) resource = "/v1/#{cluster_name}" execute(RestParameter.new(:get, resource, cano_resource: 'database', query_params: list_params(options))) end
delete_database(cluster_name, db_name)
click to toggle source
# File lib/dag/client/api/database.rb, line 34 def delete_database(cluster_name, db_name) execute(RestParameter.new(:delete, "/v1/#{cluster_name}/#{db_name}", content_type: 'application/json', cano_resource: "database")) end
Private Instance Methods
hive_reserved_word?(word)
click to toggle source
# File lib/dag/client/api/database.rb, line 40 def hive_reserved_word?(word) %w( true false all and or not like asc desc order by group where from as select distinct insert overwrite outer join left right full on partition partitions table tables tblproperties show msck directory local locks transform using cluster distribute sort union load data inpath is null create external alter describe drop reanme to comment boolean tinyint smallint int bigint float double date datetime timestamp string binary array map reduce partitioned clustered sorted into buckets row format delimited fields terminated collection items keys lines stored sequencefile textfile inputformat outputformat location tablesample bucket out of cast add replace columns rlike regexp temporary function explain extended serde with serdeproperties limit set tblproperties ).include?(word) end