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

fix(metadb): handle durations #25727

Merged
merged 1 commit into from
Oct 20, 2023
Merged

fix(metadb): handle durations #25727

merged 1 commit into from
Oct 20, 2023

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Oct 20, 2023

SUMMARY

Update the meta database extension to support intervals.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Create a table with an interval column. For example, for Postgres:

-- Create the "call_log" table
CREATE TABLE public.call_log (
    historyid serial PRIMARY KEY,
    callid character varying(128),
    duration interval,
    time_start timestamp with time zone,
    time_answered timestamp with time zone,
    time_end timestamp with time zone,
    reason_terminated character varying(128),
    from_no character varying(128),
    to_no character varying(128),
    from_dn character varying(128),
    to_dn character varying(128),
    dial_no character varying(128),
    reason_changed character varying(128),
    final_number character varying(128),
    final_dn character varying(128),
    chain text,
    from_type character varying(128),
    to_type character varying(128),
    final_type character varying(128),
    from_dispname character varying(256),
    to_dispname character varying(128),
    final_dispname character varying(128),
    missed_queue_calls text,
    c3cx_source character varying(128),
    c3cx_time_received timestamp with time zone,
    start_time timestamp with time zone,
    end_time timestamp with time zone,
    ringing_dur interval,
    talking_dur interval,
    q_wait_dur interval
);

Add some data:

-- Insert some sample data
INSERT INTO public.call_log (
    callid,
    duration,
    time_start,
    time_answered,
    time_end,
    reason_terminated,
    from_no,
    to_no,
    from_dn,
    to_dn,
    dial_no,
    reason_changed,
    final_number,
    final_dn,
    chain,
    from_type,
    to_type,
    final_type,
    from_dispname,
    to_dispname,
    final_dispname,
    missed_queue_calls,
    c3cx_source,
    c3cx_time_received,
    start_time,
    end_time,
    ringing_dur,
    talking_dur,
    q_wait_dur
) VALUES
    ('12345', '00:15:30', '2023-10-20 08:00:00', '2023-10-20 08:05:00', '2023-10-20 08:15:30', 'Completed', '123456789', '987654321', 'John Doe', 'Jane Smith', '987654321', 'Changed', '999999999', 'Final', 'Chain1', 'Type1', 'Type2', 'Type3', 'John Doe', 'Jane Smith', 'Final Person', 'Queue Missed', 'Source1', '2023-10-20 08:00:00', '2023-10-20 08:00:00', '2023-10-20 08:15:30', '00:00:30', '00:14:30', '00:00:05');

INSERT INTO public.call_log (
    callid,
    duration,
    time_start,
    time_answered,
    time_end,
    reason_terminated,
    from_no,
    to_no,
    from_dn,
    to_dn,
    dial_no,
    reason_changed,
    final_number,
    final_dn,
    chain,
    from_type,
    to_type,
    final_type,
    from_dispname,
    to_dispname,
    final_dispname,
    missed_queue_calls,
    c3cx_source,
    c3cx_time_received,
    start_time,
    end_time,
    ringing_dur,
    talking_dur,
    q_wait_dur
) VALUES
    ('67890', '00:10:45', '2023-10-20 09:30:00', '2023-10-20 09:32:00', '2023-10-20 09:42:45', 'Completed', '555555555', '444444444', 'Alice Johnson', 'Bob Brown', '444444444', 'Changed', '777777777', 'Final', 'Chain2', 'Type4', 'Type5', 'Type6', 'Alice Johnson', 'Bob Brown', 'Final Person 2', 'Queue Missed 2', 'Source2', '2023-10-20 09:30:00', '2023-10-20 09:30:00', '2023-10-20 09:42:45', '00:00:15', '00:10:30', '00:01:45');

Screenshot 2023-10-20 at 16-31-21 Superset

Query the data using the meta database:

SELECT duration FROM "examples.call_log"

Screenshot 2023-10-20 at 16-31-11 Superset

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@betodealmeida betodealmeida linked an issue Oct 20, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #25727 (ab6d5a6) into master (4ac8f82) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #25727      +/-   ##
==========================================
- Coverage   69.01%   69.01%   -0.01%     
==========================================
  Files        1935     1935              
  Lines       75606    75609       +3     
  Branches     8415     8415              
==========================================
  Hits        52182    52182              
- Misses      21264    21267       +3     
  Partials     2160     2160              
Flag Coverage Δ
hive 53.67% <100.00%> (+<0.01%) ⬆️
javascript 56.16% <ø> (-0.01%) ⬇️
mysql 78.35% <100.00%> (+<0.01%) ⬆️
postgres 78.45% <100.00%> (+<0.01%) ⬆️
presto 53.63% <100.00%> (+<0.01%) ⬆️
python 82.91% <100.00%> (+<0.01%) ⬆️
sqlite 77.10% <100.00%> (+<0.01%) ⬆️
unit 55.49% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
superset/extensions/metadb.py 84.35% <100.00%> (+0.26%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@betodealmeida betodealmeida merged commit ed87470 into master Oct 20, 2023
57 checks passed
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
@mistercrunch mistercrunch deleted the meta_duration branch March 26, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Querying trough the Meta Database fails for some tables
3 participants