How to decode a string in scala to json payload? - scala

I have a sample event which contains a string encoded value which has to decoded.What is the best way to decode and make it as json payload to load into kinesis.
"errors": [
{
"level": "error",
"message": "error: instance value (\"category\") not found in enum (possible values: [\"article\",\"section\",\"account\",\"subscription\",\"game\",\"tool\",\"stock\",\"gallery\",\"slideshow\",\"video\",\"error\",\"utility\",\"page\",\"funnel\",\"conversion\",\"(not provided)\"])\n level: \"error\"\n schema: {\"loadingURI\":\"#\",\"pointer\":\"/properties/type\"}\n instance: {\"pointer\":\"/type\"}\n domain: \"validation\"\n keyword: \"enum\"\n value: \"category\"\n enum: [\"article\",\"section\",\"account\",\"subscription\",\"game\",\"tool\",\"stock\",\"gallery\",\"slideshow\",\"video\",\"error\",\"utility\",\"page\",\"funnel\",\"conversion\",\"(not provided)\"]\n"
}
],
"failure_tstamp": "2021-02-22T18:30:06.276Z",
"line": "CwBkAAAADjE5Mi4xNDMuNTcuMjAyCgDIAAABd8sBcjwLANIAAAAFVVRGLTgLANwAAAASc3NjLTAuMTUuMC1raW5lc2lzCwEsAAAAbU1vemlsbGEvNS4wIChpUGhvbmU7IENQVSBpUGhvbmUgT1MgMTRfNCBsaWtlIE1hYyBPUyBYKSBBcHBsZVdlYktpdC82MDUuMS4xNSAoS0hUTUwsIGxpa2UgR2Vja28pIE1vYmlsZS8xNUUxNDgLATYAAAAhaHR0cHM6Ly9wdWJhZHMuZy5kb3VibGVjbGljay5uZXQvCwFAAAAAIy9jb20uc25vd3Bsb3dhbmFseXRpY3Muc25vd3Bsb3cvdHAyCwFUAAAKz3sic2NoZW1hIjoiaWdsdTpjb20uc25vd3Bsb3dhbmFseXRpY3Muc25vd3Bsb3cvcGF5bG9hZF9kYXRhL2pzb25zY2hlbWEvMS0wLTQiLCJkYXRhIjpbeyJlIjoidWUiLCJ1ZV9wciI6IntcInNjaGVtYVwiOlwiaWdsdTpjb20uc25vd3Bsb3dhbmFseXRpY3Muc25vd3Bsb3cvdW5zdHJ1Y3RfZXZlbnQvanNvbnNj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GxpY2F0aW9uL2pzb24LAWgAAAAQYXBwbGljYXRpb24vanNvbgsBkAAAABllbmRwb2ludC5zb3BoaS5uZXdzMjQuY29tCwGaAAAAJDY3NThlNDEzLWViMjQtNDJhOC05NmU5LTBiY2JhNGE0YmMxZQt6aQAAAEFpZ2x1OmNvbS5zbm93cGxvd2FuYWx5dGljcy5zbm93cGxvdy9Db2xsZWN0b3JQYXlsb2FkL3RocmlmdC8xLTAtMAA="
}
I was trying to read as below in code but its not
val sJson = JsonMethods.parse("{\n \"errors\": [\n {\n \"level\": \"error\",\n \"message\": \"error: instance value (\\\"category\\\") not found in enum (possible values: [\\\"article\\\",\\\"section\\\",\\\"account\\\",\\\"subscription\\\",\\\"game\\\",\\\"tool\\\",\\\"stock\\\",\\\"gallery\\\",\\\"slideshow\\\",\\\"video\\\",\\\"error\\\",\\\"utility\\\",\\\"page\\\",\\\"funnel\\\",\\\"conversion\\\",\\\"(not provided)\\\"])\\n level: \\\"error\\\"\\n schema: {\\\"loadingURI\\\":\\\"#\\\",\\\"pointer\\\":\\\"/properties/type\\\"}\\n instance: {\\\"pointer\\\":\\\"/type\\\"}\\n domain: \\\"validation\\\"\\n keyword: \\\"enum\\\"\\n value: \\\"category\\\"\\n enum: [\\\"article\\\",\\\"section\\\",\\\"account\\\",\\\"subscription\\\",\\\"game\\\",\\\"tool\\\",\\\"stock\\\",\\\"gallery\\\",\\\"slideshow\\\",\\\"video\\\",\\\"error\\\",\\\"utility\\\",\\\"page\\\",\\\"funnel\\\",\\\"conversion\\\",\\\"(not provided)\\\"]\\n\"\n }\n ],\n \"failure_tstamp\": \"2021-02-22T18:30:06.276Z\",\n \"line\": \"CwBkAAAADjE5Mi4xNDMuNTcuMjAyCgDIAAABd8sBcjwLANIAAAAFVVRGLTgLANwAAAASc3NjLTAuMTUuMC1raW5lc2lzCwEsAAAAbU1vemlsbGEvNS4wIChpUGhvbmU7IENQVSBpUGhvbmUgT1MgMTRfNCBsaWtlIE1hYyBPUyBYKSBB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XQAAAAqUmVmZXJlcjogaHR0cHM6Ly9wdWJhZHMuZy5kb3VibGVjbGljay5uZXQvAAAAH1gtRm9yd2FyZGVkLUZvcjogMTkyLjE0My41Ny4yMDIAAAArWC1Gb3J3YXJkZWQtSG9zdDogZW5kcG9pbnQuc29waGkubmV3czI0LmNvbQAAABVYLUZvcndhcmRlZC1Qb3J0OiA0NDMAAAAYWC1Gb3J3YXJkZWQtUHJvdG86IGh0dHBzAAAARFgtRm9yd2FyZGVkLVNlcnZlcjogdHJhZWZpay1leHRlcm5hbC1yZWQtdHJhZWZpay1oYS02Yzg2ODY5NDc5LWN4c3JzAAAAGVgtUmVhbC1JcDogMTkyLjE0My41Ny4yMDIAAAAbVGltZW91dC1BY2Nlc3M6IDxmdW5jdGlvbjE+AAAAEGFwcGxpY2F0aW9uL2pzb24LAWgAAAAQYXBwbGljYXRpb24vanNvbgsBkAAAABllbmRwb2ludC5zb3BoaS5uZXdzMjQuY29tCwGaAAAAJDY3NThlNDEzLWViMjQtNDJhOC05NmU5LTBiY2JhNGE0YmMxZQt6aQAAAEFpZ2x1OmNvbS5zbm93cGxvd2FuYWx5dGljcy5zbm93cGxvdy9Db2xsZWN0b3JQYXlsb2FkL3RocmlmdC8xLTAtMAA=\"\n}")
val payloadJsonValue = sJson \ "line"
val payvalue = JsonMethods.compact(JsonMethods.render(payloadJsonValue)).replace("\"", "")
val payloadBytes = base64Decoder.decode(payvalue)
print(payloadBytes.map(_.toChar).mkString)
Any way it can be decoded and converted as json payload

Related

I am trying to use ApiextensionsV1beta1Api to create a custom resource definition though kubernetes python client

I am trying to use ApiextensionsV1beta1Api to create a custom resource definition though kubernetes python client
with kubernetes.client.ApiClient(configuration) as api_client:
self.client_custom_resource_def = kubernetes.client.ApiextensionsV1beta1Api(api_client)
spec = {"group": "kgosalia.com", "scope": "Namespaced",
"metadata": {"name": "kgosaliaconfigs.kgosalia.com"},
"versions": [{"name": "v1", "served": True, "storage": True}],
"names": {"kind": "CustomResourceDefinition", "plural": "kgosaliaconfigs"}}
def create_custom_resource_definition(self, spec):
body = kubernetes.client.V1beta1CustomResourceDefinition(spec=spec)
try:
api_response = self.client_custom_resource_def.create_custom_resource_definition(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling ApiextensionsV1Api->create_custom_resource_definition: %s\n" % e)
When I run this I am getting a 422. Can you help me find the correct format to create spec and name object?
{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"CustomResourceDefinition.apiextensions.k8s.io \"\" is invalid: metadata.name: Required value: name or generateName is required","reason":"Invalid","details":{"group":"apiextensions.k8s.io","kind":"CustomResourceDefinition","causes":[{"reason":"FieldValueRequired","message":"Required value: name or generateName is required","field":"metadata.name"}]},"code":422}
Appreciate your help, thank you!

play.api.libs.json is not able to parse uuid string

In scala play application, I am trying to parse uuid as a json response but getting error:
play.api.libs.json.Json.parse(s"""
{
"id" : "ac435876-fe73-4385-a9dd-af54ce2d7a7d"
}
""")
Error- play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[JsonParseException: Unrecognized token 'C': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (String)"

How to get Quantile/median values in pydruid

My goal is to query the median value of column height in my druid datasource. I was able to use other aggregations like count and count distinct values. Here's my query so far:
group = query.groupby(
datasource=datasource,
granularity='all',
intervals='2020-01-01T00:00:00+00:00/2101-01-01T00:00:00+00:00',
dimensions=[
"category_a"
],
filter=(Dimension("country") == country_id),
aggregations={
'count': longsum('count'),
'count_distinct_city': aggregators.thetasketch('city'),
}
)
There's a class Quantile under postaggregator.py so I tried using this.
class Quantile(Postaggregator):
def __init__(self, name, probability):
Postaggregator.__init__(self, None, None, name)
self.post_aggregator = {
"type": "quantile",
"fieldName": name,
"probability": probability,
}
Here's my attempt at getting the median:
post_aggregations={
'median_value': postaggregator.Quantile(
'height', 50
)
}
The error I'm getting here is 'Could not resolve type id \'quantile\' as a subtype of [simple type, class io.druid.query.aggregation.PostAggregator]:
Druid Error: {'error': 'Unknown exception', 'errorMessage': 'Could not resolve type id \'quantile\' as a subtype of [simple type, class io.druid.query.aggregation.PostAggregator]: known type ids = [arithmetic, constant, doubleGreatest, doubleLeast, expression, fieldAccess, finalizingFieldAccess, hyperUniqueCardinality, javascript, longGreatest, longLeast, quantilesDoublesSketchToHistogram, quantilesDoublesSketchToQuantile, quantilesDoublesSketchToQuantiles, quantilesDoublesSketchToString, sketchEstimate, sketchSetOper, thetaSketchEstimate, thetaSketchSetOp] (for POJO property \'postAggregations\')\n at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 856] (through reference chain: io.druid.query.groupby.GroupByQuery["postAggregations"]->java.util.ArrayList[0])', 'errorClass': 'com.fasterxml.jackson.databind.exc.InvalidTypeIdException', 'host': None}
I modified the code of pydruid to get this working on our end. I've created new aggregator and postaggregator under /pydruid/utils.
aggregator.py
def quantilesDoublesSketch(raw_column, k=128):
return {"type": "quantilesDoublesSketch", "fieldName": raw_column, "k": k}
postaggregator.py
class QuantilesDoublesSketchToQuantile(Postaggregator):
def __init__(self, name: str, field_name: str, fraction: float):
self.post_aggregator = {
"type": "quantilesDoublesSketchToQuantile",
"name": name,
"fraction": fraction,
"field": {
"fieldName": field_name,
"name": field_name,
"type": "fieldAccess",
},
}
My first time to create a PR! Hopefully they accept and publish officially.
https://github.com/druid-io/pydruid/pull/287

'TypeError: StructType can not accept object

I'm trying to convert this json string data to Dataframe in Databricks
a = """{ "id": "a",
"message_type": "b",
"data": [ {"c":"abcd","timestamp":"2022-03-
01T13:10:00+00:00","e":0.18,"f":0.52} ]}"""
the schema I defined for the data is this
schema=StructType(
[
StructField("id",StringType(),False),
StructField("message_type",StringType(),False),
StructField("data", ArrayType(StructType([
StructField("c",StringType(),False),
StructField("timestamp",StringType(),False),
StructField("e",DoubleType(),False),
StructField("f",DoubleType(),False),
])))
,
]
)
and when I run this command
df = sqlContext.createDataFrame(sc.parallelize([a]), schema)
I get this error
PythonException: 'TypeError: StructType can not accept object '{ "id": "a",\n"message_type": "JobMetric",\n"data": [ {"c":"abcd","timestamp":"2022-03- \n01T13:10:00+00:00","e":0.18,"f":0.52=} ]' in type <class 'str'>'. Full traceback below:
anyone could help me with this, would much appreciate it!
Your a variable is wrong.
"data": [ "{"JobId":"ATLUPS10m2101V1","Timestamp":"2022-03-
01T13:10:00+00:00","number1":0.9098145961761475,"number2":0.5294908881187439}" ]
Should be
"data": [ {"JobId":"ATLUPS10m2101V1","Timestamp":"2022-03-
01T13:10:00+00:00","number1":0.9098145961761475,"number2":0.5294908881187439} ]
And check if it is OK to match name with JobId to job_id and Timestamp to timestamp.
Issue is whenever you're passing the string object to struct schema it expects RDD([StringType, StringType,...]) however, in your current scenario it is getting just string object. In order to fix it first you need to convert your string to a json object and from there you'll need to create a RDD. See the below logic for details -
Input Data -
a = """{"run_id": "1640c68e-5f02-4f49-943d-37a102f90146",
"message_type": "JobMetric",
"data": [ {"JobId":"ATLUPS10m2101V1","timestamp":"2022-03-01T13:10:00+00:00",
"score":0.9098145961761475,
"severity":0.5294908881187439
}
]
}"""
Converting to a RDD using json object -
from pyspark.sql.types import *
import json
schema=StructType(
[
StructField("run_id",StringType(),False),
StructField("message_type",StringType(),False),
StructField("data", ArrayType(StructType([
StructField("JobId",StringType(),False),
StructField("timestamp",StringType(),False),
StructField("score",DoubleType(),False),
StructField("severity",DoubleType(),False),
])))
,
]
)
df = spark.createDataFrame(data=sc.parallelize([json.loads(a)]),schema=schema)
df.show(truncate=False)
Output -
+------------------------------------+------------+--------------------------------------------------------------------------------------+
|run_id |message_type|data |
+------------------------------------+------------+--------------------------------------------------------------------------------------+
|1640c68e-5f02-4f49-943d-37a102f90146|JobMetric |[{ATLUPS10m2101V1, 2022-03-01T13:10:00+00:00, 0.9098145961761475, 0.5294908881187439}]|
+------------------------------------+------------+--------------------------------------------------------------------------------------+

Openapi3 and CSV response (for Dredd)

I test my Api with DREDD against it's specification (written in Openapi3 considering, painfull limitations of Support by Dredd considered). No I have one endpoint, which produces CSV-data if the Accept-header is set so.
'/my-endpoint':
summary: ...
description: ...
get:
# parameters:
# -
# in: header
# name: Accept
# description: "Response format: application/json or text/csv"
# example: "text/csv"
responses:
'200':
description: ...
content:
text/csv:
schema:
type: string
example:
summary: 'csv table'
value: 'cell1, cell2'
When I run the test with Dredd the test fails with
expected:
headers:
body:
[
{
"key": "summary",
"value": "csv table"
},
{
"key": "value",
"value": "cell1, cell2"
}
]
statusCode: 200
Clearly there is something misunderstood and Dredd expects still JSON. Also the API is not told to produce the CSV Version. If I commit in the Accept header in the code abvoe I get the very same result - the expecetd result above and as actual result the JSON version of the my-endpoint-data and also ad warning:
warn: API description parser warning in .../tmp/transformed.specs.yml: 'Parameter Object' 'name' in location 'header' should not be 'Accept', 'Content-Type' or 'Authorization'
I read here and here: Header parameters named Accept, Content-Type and Authorization are not allowed. To describe these headers, use the corresponding OpenAPI keywords - but what are they? According to this and this page it seems to be enough to specify a response of the given type but that is clearly not enough to tell Dredd to produce such a header.
You got an error because the value of the example key is meant to be a literal example value. So in your case it's treated as an object with the summary and value properties.
Change your definition to:
content:
text/csv:
schema:
type: string
example: 'cell1, cell2'
Or if you want to provide a summary/description for an example, use examples instead:
content:
text/csv:
schema:
type: string
examples:
csv table:
summary: A CSV table with 2 cells
value: 'cell1, cell2'