Flow Service API를 사용하여 소스에 대한 행 수준 데이터 필터링
이 자습서에서는 Flow Service API를 사용하여 소스에 대한 행 수준 데이터를 필터링하는 방법에 대한 단계를 제공합니다.
시작하기
이 자습서를 사용하려면 Adobe Experience Platform의 다음 구성 요소를 잘 알고 있어야 합니다.
Platform API 사용
Platform API를 성공적으로 호출하는 방법에 대한 자세한 내용은 Platform API 시작에 대한 안내서를 참조하십시오.
소스 데이터 필터링
다음은 소스에 대한 행 수준 데이터를 필터링하기 위해 수행해야 하는 단계입니다.
연결 사양 조회
API를 사용하여 소스에 대한 행 수준 데이터를 필터링하려면 먼저 소스의 연결 사양 세부 정보를 검색하여 특정 소스가 지원하는 연산자 및 언어를 확인해야 합니다.
지정된 소스의 연결 사양을 검색하려면 쿼리 매개 변수의 일부로 소스의 속성 이름을 제공하면서 Flow Service API의 /connectionSpecs
끝점에 GET 요청을 하십시오.
API 형식
GET /connectionSpecs/{QUERY_PARAMS}
{QUERY_PARAMS}
name
속성을 적용하고 검색에서 "google-big-query"
을(를) 지정하여 Google BigQuery 연결 사양을 검색할 수 있습니다.요청
다음 요청은 Google BigQuery에 대한 연결 사양을 검색합니다.
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connectionSpecs?property=name=="google-big-query"' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
응답
성공한 응답은 지원되는 쿼리 언어 및 논리 연산자에 대한 정보를 포함하여 Google BigQuery에 대한 연결 사양을 반환합니다.
"attributes": {
"filterAtSource": {
"enabled": true,
"queryLanguage": "SQL",
"logicalOperators": [
"and",
"or",
"not"
],
"comparisonOperators": [
"=",
"!=",
"<",
"<=",
">",
">=",
"like",
"in"
],
"columnNameEscapeChar": "`",
"valueEscapeChar": "'"
}
attributes.filterAtSource.enabled
attributes.filterAtSource.queryLanguage
attributes.filterAtSource.logicalOperators
attributes.filterAtSource.comparisonOperators
attributes.filterAtSource.columnNameEscapeChar
attributes.filterAtSource.valueEscapeChar
비교 연산자
==
!=
<
>
<=
>=
like
WHERE
절에 사용되어 필터링합니다.in
수집을 위한 필터링 조건 지정
소스에서 지원하는 논리 연산자 및 쿼리 언어를 식별한 후에는 Profile Query Language(PQL)를 사용하여 소스 데이터에 적용할 필터링 조건을 지정할 수 있습니다.
아래 예에서는 매개 변수로 나열된 노드 유형에 대해 제공된 값과 동일한 선택 데이터에만 조건이 적용됩니다.
{
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "=",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "city"
},
{
"nodeType": "literal",
"value": "DDN"
}
]
}
}
데이터 미리 보기
filters
을(를) 쿼리 매개 변수의 일부로 제공하고 Base64에서 PQL 입력 조건을 지정하는 동안 Flow Service API의 /explore
끝점에 GET 요청을 하여 데이터를 미리 볼 수 있습니다.
API 형식
GET /connections/{BASE_CONNECTION_ID}/explore?objectType=table&object={TABLE_PATH}&preview=true&filters={FILTERS}
{BASE_CONNECTION_ID}
{TABLE_PATH}
{FILTERS}
요청
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/89d1459e-3cd0-4069-acb3-68f240db4eeb/explore?objectType=table&object=TESTFAS.FASTABLE&preview=true&filters=ewogICJ0eXBlIjogIlBRTCIsCiAgImZvcm1hdCI6ICJwcWwvanNvbiIsCiAgInZhbHVlIjogewogICAgIm5vZGVUeXBlIjogImZuQXBwbHkiLAogICAgImZuTmFtZSI6ICJhbmQiLAogICAgInBhcmFtcyI6IFsKICAgICAgewogICAgICAgICJub2RlVHlwZSI6ICJmbkFwcGx5IiwKICAgICAgICAiZm5OYW1lIjogImxpa2UiLAogICAgICAgICJwYXJhbXMiOiBbCiAgICAgICAgICB7CiAgICAgICAgICAgICJub2RlVHlwZSI6ICJmaWVsZExvb2t1cCIsCiAgICAgICAgICAgICJmaWVsZE5hbWUiOiAiY2l0eSIKICAgICAgICAgIH0sCiAgICAgICAgICB7CiAgICAgICAgICAgICJub2RlVHlwZSI6ICJsaXRlcmFsIiwKICAgICAgICAgICAgInZhbHVlIjogIk0lIgogICAgICAgICAgfQogICAgICAgIF0KICAgICAgfQogICAgXQogIH0KfQ==\' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
응답
성공적인 요청은 다음 응답을 반환합니다.
{
"format": "flat",
"schema": {
"columns": [
{
"name": "FIRSTNAME",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "LASTNAME",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "CITY",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "AGE",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "HEIGHT",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "ISEMPLOYED",
"type": "boolean",
"xdm": {
"type": "boolean"
}
},
{
"name": "POSTG",
"type": "boolean",
"xdm": {
"type": "boolean"
}
},
{
"name": "LATITUDE",
"type": "double",
"xdm": {
"type": "number"
}
},
{
"name": "LONGITUDE",
"type": "double",
"xdm": {
"type": "number"
}
},
{
"name": "JOINEDDATE",
"type": "string",
"meta:xdmType": "date-time",
"xdm": {
"type": "string",
"format": "date-time"
}
},
{
"name": "CREATEDAT",
"type": "string",
"meta:xdmType": "date-time",
"xdm": {
"type": "string",
"format": "date-time"
}
},
{
"name": "CREATEDATTS",
"type": "string",
"meta:xdmType": "date-time",
"xdm": {
"type": "string",
"format": "date-time"
}
}
]
},
"data": [
{
"CITY": "MZN",
"LASTNAME": "Jain",
"JOINEDDATE": "2022-06-22T00:00:00",
"LONGITUDE": 1000.222,
"CREATEDAT": "2022-06-22T17:19:33",
"FIRSTNAME": "Shivam",
"POSTG": true,
"HEIGHT": "169",
"CREATEDATTS": "2022-06-22T17:19:33",
"ISEMPLOYED": true,
"LATITUDE": 2000.89,
"AGE": "25"
},
{
"CITY": "MUM",
"LASTNAME": "Kreet",
"JOINEDDATE": "2022-09-07T00:00:00",
"LONGITUDE": 10500.01,
"CREATEDAT": "2022-09-07T17:19:33",
"FIRSTNAME": "Rakul",
"POSTG": true,
"HEIGHT": "155",
"CREATEDATTS": "2022-09-07T17:19:33",
"ISEMPLOYED": false,
"LATITUDE": 2500.89,
"AGE": "42"
},
{
"CITY": "MAN",
"LASTNAME": "Lee",
"JOINEDDATE": "2022-09-14T00:00:00",
"LONGITUDE": 1000.222,
"CREATEDAT": "2022-09-14T05:02:33",
"FIRSTNAME": "Denzel",
"POSTG": true,
"HEIGHT": "185",
"CREATEDATTS": "2022-09-14T05:02:33",
"ISEMPLOYED": true,
"LATITUDE": 123.89,
"AGE": "16"
}
]
}
필터링된 데이터에 대한 소스 연결 만들기
원본 연결을 만들고 필터링된 데이터를 수집하려면 본문 매개 변수의 일부로 필터링 조건을 제공하는 동안 /sourceConnections
끝점에 대한 POST 요청을 만듭니다.
API 형식
POST /sourceConnections
요청
다음 요청은 city
= DDN
인 test1.fasTestTable
에서 데이터를 수집하기 위한 원본 연결을 만듭니다.
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/sourceConnections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "BigQuery Source Connection",
"description": "Source Connection for Filter test",
"baseConnectionId": "89d1459e-3cd0-4069-acb3-68f240db4eeb",
"data": {
"format": "tabular"
},
"params": {
"tableName": "test1.fasTestTable",
"filters": {
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "=",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "city"
},
{
"nodeType": "literal",
"value": "DDN"
}
]
}
}
},
"connectionSpec": {
"id": "3c9b37f8-13a6-43d8-bad3-b863b941fedd",
"version": "1.0"
}
}'
응답
성공한 응답은 새로 만든 원본 연결의 고유 식별자(id
)를 반환합니다.
{
"id": "b7581b59-c603-4df1-a689-d23d7ac440f3",
"etag": "\"ef05d265-0000-0200-0000-6019e0080000\""
}
부록
이 섹션에서는 필터링에 대한 다양한 페이로드의 추가 예를 제공합니다.
단일 조건
조건이 하나만 필요한 시나리오의 경우 초기 fnApply
을(를) 생략할 수 있습니다.
{
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "like",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "firstname"
},
{
"nodeType": "literal",
"value": "%s"
}
]
}
}
in
연산자 사용
in
연산자의 예제를 보려면 아래 샘플 페이로드를 참조하십시오.
{
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "and",
"params": [
{
"nodeType": "fnApply",
"fnName": "in",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "firstname"
},
{
"nodeType": "literal",
"value": [
"Ramen",
"John"
]
}
]
}
]
}
}
isNull
연산자 사용
isNull
연산자의 예제를 보려면 아래 샘플 페이로드를 참조하십시오.
{
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "isNull",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "complaint_type"
}
]
}
}
NOT
연산자 사용
NOT
연산자의 예제를 보려면 아래 샘플 페이로드를 참조하십시오.
{
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "NOT",
"params": [
{
"nodeType": "fnApply",
"fnName": "isNull",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "complaint_type"
}
]
}
]
}
}
중첩된 조건이 있는 예
복잡한 중첩 조건의 예는 아래의 샘플 페이로드를 참조하십시오.
{
"type": "PQL",
"format": "pql/json",
"value": {
"nodeType": "fnApply",
"fnName": "and",
"params": [
{
"nodeType": "fnApply",
"fnName": ">=",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "age"
},
{
"nodeType": "literal",
"value": 20
}
]
},
{
"nodeType": "fnApply",
"fnName": "<=",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "age"
},
{
"nodeType": "literal",
"value": 30
}
]
},
{
"nodeType": "fnApply",
"fnName": "or",
"params": [
{
"nodeType": "fnApply",
"fnName": "!=",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "city"
},
{
"nodeType": "literal",
"value": "PUD"
}
]
},
{
"nodeType": "fnApply",
"fnName": "=",
"params": [
{
"nodeType": "fieldLookup",
"fieldName": "joinedDate"
},
{
"nodeType": "literal",
"value": "2020-04-22"
}
]
}
]
}
]
}
}