Class: Superset::Dataset::UpdateQuery

Inherits:
Request
  • Object
show all
Defined in:
lib/superset/dataset/update_query.rb

Constant Summary

Constants inherited from Request

Request::PAGE_SIZE

Instance Attribute Summary collapse

Attributes inherited from Request

#page_num

Instance Method Summary collapse

Methods inherited from Request

call, #query_params, #result, #superset_host

Methods included from Superset::Display

#display_headers, #headings, #list, #list_attributes, #result, #rows, #table, #title

Constructor Details

#initialize(dataset_id:, new_query:) ⇒ UpdateQuery

Returns a new instance of UpdateQuery.



7
8
9
10
# File 'lib/superset/dataset/update_query.rb', line 7

def initialize(dataset_id: ,new_query: )
  @new_query = new_query
  @dataset_id = dataset_id
end

Instance Attribute Details

#dataset_idObject (readonly)

Returns the value of attribute dataset_id.



5
6
7
# File 'lib/superset/dataset/update_query.rb', line 5

def dataset_id
  @dataset_id
end

#new_queryObject (readonly)

Returns the value of attribute new_query.



5
6
7
# File 'lib/superset/dataset/update_query.rb', line 5

def new_query
  @new_query
end

Instance Method Details

#paramsObject



22
23
24
# File 'lib/superset/dataset/update_query.rb', line 22

def params
  { "sql": new_query }
end

#performObject



12
13
14
15
16
# File 'lib/superset/dataset/update_query.rb', line 12

def perform
  validate_proposed_changes

  response
end

#responseObject



18
19
20
# File 'lib/superset/dataset/update_query.rb', line 18

def response
  @response ||= client.put(route, params)
end

#source_datasetObject



31
32
33
34
35
36
37
# File 'lib/superset/dataset/update_query.rb', line 31

def source_dataset
  # will raise an error if the dataset does not exist
  @source_dataset ||= begin
    dataset = Get.new(dataset_id)
    dataset.result
  end
end

#sql_query_includes_hard_coded_schema?Boolean

check if the sql query embedds the schema name, if so it can not be duplicated cleanly

Returns:

  • (Boolean)


27
28
29
# File 'lib/superset/dataset/update_query.rb', line 27

def sql_query_includes_hard_coded_schema?
  new_query.include?("#{source_dataset['schema']}.")
end