Amazon Chime SDKコール分析用の AWS Glue データカタログ内のデータの抽出 - Amazon Chime SDK

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

Amazon Chime SDKコール分析用の AWS Glue データカタログ内のデータの抽出

これらのサンプルクエリを使用して、Amazon Chime SDKコール分析 Glue データカタログ内のデータを抽出および整理します。

注記

Amazon Athena への接続と Glue データカタログのクエリについては、「 を使用した Amazon Athena への接続ODBC」を参照してください。

必要に応じて各セクションを展開してください。

call_analytics_metadata には、JSON文字列形式の metadataフィールドがあります。Athena の json_extract_scalar 関数を使用して、この文字列の要素をクエリします。

SELECT json_extract_scalar(metadata,'$.voiceConnectorId') AS "VoiceConnector ID", json_extract_scalar(metadata,'$.fromNumber') AS "From Number", json_extract_scalar(metadata,'$.toNumber') AS "To Number", json_extract_scalar(metadata,'$.callId') AS "Call ID", json_extract_scalar(metadata,'$.direction') AS Direction, json_extract_scalar(metadata,'$.transactionId') AS "Transaction ID" FROM "GlueDatabaseName"."call_analytics_metadata"

call_analytics_metadata フィールドにはJSON、文字列形式のメタデータフィールドがあります。 metadata には、 という名前の別のネストされたオブジェクトがあります。このオブジェクトにはoneTimeMetadata、元の形式XMLと変換されたJSON形式のSIPRecメタデータが含まれます。Athena の json_extract_scalar 関数を使用して、この文字列の要素をクエリします。

SELECT json_extract_scalar(metadata,'$.voiceConnectorId') AS "VoiceConnector ID", json_extract_scalar(metadata,'$.fromNumber') AS "From Number", json_extract_scalar(metadata,'$.toNumber') AS "To Number", json_extract_scalar(metadata,'$.callId') AS "Call ID", json_extract_scalar(metadata,'$.direction') AS Direction, json_extract_scalar(metadata,'$.transactionId') AS "Transaction ID", json_extract_scalar(json_extract_scalar(metadata,'$.oneTimeMetadata'),'$.siprecMetadata') AS "siprec Metadata XML", json_extract_scalar(json_extract_scalar(metadata,'$.oneTimeMetadata'),'$.siprecMetadataJson') AS "Siprec Metadata JSON", json_extract_scalar(json_extract_scalar(metadata,'$.oneTimeMetadata'),'$.inviteHeaders') AS "Invite Headers" FROM "GlueDatabaseName"."call_analytics_metadata" WHERE callevent-type = "update";

call_analytics_recording_metadata には、JSON文字列形式のメタデータフィールドがあります。Athena の json_extract_scalar 関数を使用して、この文字列の要素をクエリします。

SELECT json_extract_scalar(metadata,'$.voiceConnectorId') AS "VoiceConnector ID", json_extract_scalar(metadata,'$.fromNumber') AS "From Number", json_extract_scalar(metadata,'$.toNumber') AS "To Number", json_extract_scalar(metadata,'$.callId') AS "Call ID", json_extract_scalar(metadata,'$.direction') AS Direction, json_extract_scalar(metadata,'$.transactionId') AS "Transaction ID" FROM "GlueDatabaseName"."call_analytics_recording_metadata" WHERE detail-subtype = "Recording"

voice_analytics_status には struct データ型の詳細フィールドがあります。次の例では、struct データ型フィールドをクエリする方法を示します。

SELECT detail.transactionId AS "Transaction ID", detail.voiceConnectorId AS "VoiceConnector ID", detail.siprecmetadata AS "Siprec Metadata", detail.inviteheaders AS "Invite Headers", detail.streamStartTime AS "Stream Start Time" FROM "GlueDatabaseName"."voice_analytics_status"

次のクエリ例では、call_analytics_metadatavoice_analytics_status を結合します。

SELECT a.detail.transactionId AS "Transaction ID", a.detail.voiceConnectorId AS "VoiceConnector ID", a.detail.siprecmetadata AS "Siprec Metadata", a.detail.inviteheaders AS "Invite Headers", a.detail.streamStartTime AS "Stream Start Time" json_extract_scalar(b.metadata,'$.fromNumber') AS "From Number", json_extract_scalar(b.metadata,'$.toNumber') AS "To Number", json_extract_scalar(b.metadata,'$.callId') AS "Call ID", json_extract_scalar(b.metadata,'$.direction') AS Direction FROM "GlueDatabaseName"."voice_analytics_status" a INNER JOIN "GlueDatabaseName"."call_analytics_metadata" b ON a.detail.transactionId = json_extract_scalar(b.metadata,'$.transactionId')

transcribe_call_analytics_post_call には、ネストされた配列を含む構造体形式のトランスクリプトフィールドがあります。次のクエリを使用して配列のネストを解除します。

SELECT jobstatus, languagecode, IF(CARDINALITY(m.transcript)=0 OR CARDINALITY(m.transcript) IS NULL, NULL, e.transcript.id) AS utteranceId, IF(CARDINALITY(m.transcript)=0 OR CARDINALITY(m.transcript) IS NULL, NULL, e.transcript.content) AS transcript, accountid, channel, sessionid, contentmetadata.output AS "Redaction" FROM "GlueDatabaseName"."transcribe_call_analytics_post_call" m CROSS JOIN UNNEST (IF(CARDINALITY(m.transcript)=0, ARRAY[NULL], transcript)) AS e(transcript)

次のクエリは、transcribe_call_analytics_post_call と call_analytics_metadata を結合します。

WITH metadata AS( SELECT from_iso8601_timestamp(time) AS "Timestamp", date_parse(date_format(from_iso8601_timestamp(time), '%m/%d/%Y %H:%i:%s') , '%m/%d/%Y %H:%i:%s') AS "DateTime", date_parse(date_format(from_iso8601_timestamp(time) , '%m/%d/%Y') , '%m/%d/%Y') AS "Date", date_format(from_iso8601_timestamp(time) , '%H:%i:%s') AS "Time", mediainsightspipelineid, json_extract_scalar(metadata,'$.toNumber') AS "To Number", json_extract_scalar(metadata,'$.voiceConnectorId') AS "VoiceConnector ID", json_extract_scalar(metadata,'$.fromNumber') AS "From Number", json_extract_scalar(metadata,'$.callId') AS "Call ID", json_extract_scalar(metadata,'$.direction') AS Direction, json_extract_scalar(metadata,'$.transactionId') AS "Transaction ID", REGEXP_REPLACE(REGEXP_EXTRACT(json_extract_scalar(metadata,'$.oneTimeMetadata.s3RecordingUrl'), '[^/]+(?=\.[^.]+$)'), '\.wav$', '') AS "SessionID" FROM "GlueDatabaseName"."call_analytics_metadata" ), transcript_events AS( SELECT jobstatus, languagecode, IF(CARDINALITY(m.transcript)=0 OR CARDINALITY(m.transcript) IS NULL, NULL, e.transcript.id) AS utteranceId, IF(CARDINALITY(m.transcript)=0 OR CARDINALITY(m.transcript) IS NULL, NULL, e.transcript.content) AS transcript, accountid, channel, sessionid, contentmetadata.output AS "Redaction" FROM "GlueDatabaseName"."transcribe_call_analytics_post_call" m CROSS JOIN UNNEST (IF(CARDINALITY(m.transcript)=0, ARRAY[NULL], transcript)) AS e(transcript) ) SELECT jobstatus, languagecode, a.utteranceId, transcript, accountid, channel, a.sessionid, "Redaction" "Timestamp", "DateTime", "Date", "Time", mediainsightspipelineid, "To Number", "VoiceConnector ID", "From Number", "Call ID", Direction, "Transaction ID" FROM "GlueDatabaseName"."transcribe_call_analytics_post_call" a LEFT JOIN metadata b ON a.sessionid = b.SessionID

次のクエリの例では、 Voice enhancement call recording を結合しますURL。

SELECT json_extract_scalar(metadata,'$.voiceConnectorId') AS "VoiceConnector ID", json_extract_scalar(metadata,'$.fromNumber') AS "From Number", json_extract_scalar(metadata,'$.toNumber') AS "To Number", json_extract_scalar(metadata,'$.callId') AS "Call ID", json_extract_scalar(metadata,'$.direction') AS Direction, json_extract_scalar(metadata,'$.transactionId') AS "Transaction ID", s3MediaObjectConsoleUrl FROM {GlueDatabaseName}."call_analytics_recording_metadata" WHERE detail-subtype = "VoiceEnhancement"