0

I am new to Python, so it might be something obvious. I am trying to do some transformation on a string variables (or even literals), but any function I use fails with:

com.incorta.api.exceptions.DataException: INC_03070101: Transformation error [Error An error occurred while calling o74.getnewargs. Trace: py4j.Py4JException: Method getnewargs([]) does not exist ('Py4JError', ':', Py4JError(u'An error occurred while calling o74.getnewargs. Trace:\npy4j.Py4JException: Method getnewargs([]) does not exist\n\tat py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)\n\tat py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)\n\tat py4j.Gateway.invoke(Gateway.java:274)\n\tat py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)\n\tat py4j.commands.CallCommand.execute(CallCommand.java:79)\n\tat py4j.GatewayConnection.run(GatewayConnection.java:238)\n\tat java.lang.Thread.run(Thread.java:750)\n\n',))

Spark version 2.4.7

Sample code:

from pyspark.sql.functions import substring
objectName = substring("fullFieldString", 1, 4)

2 Answers 2

0

I don’t know what you try to achieve but the usage of substring in pyspark is as following.

https://spark.apache.org/docs/3.1.1/api/python/reference/api/pyspark.sql.functions.substring.html

Sign up to request clarification or add additional context in comments.

1 Comment

I am parsing XML (which is stored in a table). I pull one attribute into a string variable. Then I am trying to split that string into 3. How to achieve it? Sample I gave was simplified without any variable, but just string constant. Does it mean all these functions will only work on data frames? BTW - is my usage not following that documentation? I am providing string, start position and length.
0

I should probably do some Python basics course first :) I found my answer here:

Strings slicing in Python

schemaName = fullFieldString[:fullFieldString.find('.')]

It seems that variables have completely separate functions set and majority of references are describing data frames functions

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.