Skip to content

Instantly share code, notes, and snippets.

@cryocaustik
Last active May 19, 2020 07:21
Show Gist options
  • Save cryocaustik/b177f1ec75bcc7eb0e712af2258540b5 to your computer and use it in GitHub Desktop.
Save cryocaustik/b177f1ec75bcc7eb0e712af2258540b5 to your computer and use it in GitHub Desktop.
MySQL Sample data for Tableau Parameter Refresh on Workbook Open Failing PoC
-- create base tables with sample data
CREATE TABLE IF NOT EXISTS tableau_pub.regions (
id INT NOT NULL,
region VARCHAR(200) NOT NULL,
created_at DATETIME NOT NULL,
modified_at DATETIME NOT NULL
);
INSERT INTO tableau_pub.regions VALUES
(1, 'Africa', NOW(), NOW()),
(2, 'Asia', NOW(), NOW()),
(3, 'Europe', NOW(), NOW()),
(4, 'Middle East', NOW(), NOW()),
(5, 'Ocenia', NOW(), NOW()),
(6, 'The Americas', NOW(), NOW())
;
CREATE TABLE IF NOT EXISTS tableau_pub.user_mapping (
id INT NOT NULL,
user_name VARCHAR(200) NOT NULL,
region_id INT NOT NULL,
created_at DATETIME NOT NULL,
modified_at DATETIME NOT NULL
);
INSERT INTO user_mapping VALUES
(1, 'Aleksandr.Skobelev', -99, NOW(), NOW()),
(2, 'John.Smith', 1, NOW(), NOW()),
(3, 'Jane.Doe', 3, NOW(), NOW())
;
-- Initial SQL for data connection to populate Region parameter
DROP TABLE IF EXISTS user;
CREATE TABLE IF NOT EXISTS user AS (
select
um.user_name,
um.region_id,
r.region
from tableau_pub.user_mapping as um
inner join tableau_pub.regions as r on r.id = um.region_id
or um.region_id = -99
where
um.user_name = [TableauServerUser]
);
-- Custom SQL Query to populate Region Parameter
select * from tableau_pub.user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment