i am getting error while using window functions in pyspark - pyspark

i am trying to run the below code
employees = (spark.read.format('csv')
.option('sep', '\t')
.schema('''EMP_ID INT,F_NAME STRING,L_NAME STRING,
EMAIL STRING,PHONE_NR STRING,HIRE_DATE STRING,
JOB_ID STRING,SALARY FLOAT,
COMMISSION_PCT STRING,
MANAGER_ID STRING,DEP_ID STRING''')
.load('C:/data/hr_db/employees')
)
spec = Window.partitionBy('DEP_ID')
emp = (employees
.select('JOB_ID', 'DEP_ID', 'SALARY')
.withColumn('Total Salary', sum('SALARY').over(spec))
.orderBy('DEP_ID')
)
emp.show()
and getting the below error
File "C:\spark-2.4.4-bin-hadoop2.7\python\lib\py4j-0.10.7-src.zip\py4j\protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o60.showString.java.lang.IllegalArgumentException: Unsupported class file major version 56
could you please anyone help me on this error?

Related

A PHP Error was encountered Severity: Notice Message: Trying to access array offset on value of type null

A PHP Error was encountered
Severity: Notice
Message: Trying to access array offset on value of type null
Filename: datauser/editsuperadmin.php
Line Number: 20
Backtrace:
File: C:\xampp\htdocs\mcicampus2\application\views\Superadmin\datauser\editsuperadmin.php
Line: 20
Function: _error_handler
File: C:\xampp\htdocs\mcicampus2\application\controllers\Superadmin.php
Line: 107
Function: view
File: C:\xampp\htdocs\mcicampus2\index.php
Line: 315
Function: require_once
This error means the index doesn't exist in array. You should use isset before printing or using the value of the array.
To check whether the index exists or not you can use isset():
isset($abc_array['xyz_data']) {
echo $abc_array['xyz_data'];
}

Getting error "Unknown error during import: <class Keyerror> : 'Field1' at row 2 resolve other errors first" in odoo 14

I have a custom module in which i want to import some of the updated data but getting an error
Unknown error during import: <class 'KeyError'>: 'field1'
at row 2 Resolve other errors first
I am getting this error in some of the fields not all.
Below are the type and description and parameters of the field in which i am getting this error:-
field1 = fields.Many2one(comodel_name="a.b", string="Field1", required=False, )
field2 = fields.Many2one(comodel_name="b.c", string="Field2", required=False, )
field3 = fields.Char('Field3', size=30, required=True)
field4 = fields.Char('Field4', size=30)
field5 = fields.Char('Field5', size=30, required=True)
After including these fields in export and import resolve this issue but if i remove any of the fields in export and import of data gives this issue again. Why is this happening?
Is this error related to migration or something else i am missing? Do anyone have any idea how to solve this issue?

postgres-rust error 42601 (Common Syntax Error): Issuing variable table names properly?

Cargo.toml:
[dependencies]
rocket = "0.4.4"
rocket_cors = "0.5.2"
postgres = "0.15.2"
r2d2_postgres = "0.14.0"
r2d2 = "0.8.0"
rocket_contrib = "0.4.4"
serde_json = "1.0.53"
I'm attempting to issue variable table names in rust-postgres by using the format! macro so that rust can handle the concatenation itself. state.val.get().unwrap().execute() is equivalent to connection.execute() in a regular usecase when equal to postgres::PostgresConnectionManager::new(). Here's the snippet:
let data_u8: &[u8] = data.peek();
let data_str: &str = str::from_utf8(&data_u8).unwrap();
let data_json: serde_json::Value = serde_json::from_str(&data_str).unwrap();
let table_name = data_json["broadcast_category"].to_string().replace(&['\"'][..], "");
let table_create = format!("CREATE TABLE IF NOT EXISTS category_{} (
message VARCHAR NOT NULL,
name VARCHAR NOT NULL,
)", table_name);
let table_create_ref: &str = &table_create[..];
println!("Table Create fn: {}", table_create);
state.val.get().unwrap().execute(table_create_ref, &[]).unwrap();
I only recieve the following error on compile-time: (data_json["broadcast_category"] is part of a serde_json::Value wrapper recieved on a POST request from the user.
Error:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error(Db(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42601"), message: "syntax error at or near \"$1\"", detail: None, hint: None, position: Some(Normal(59)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1133), routine: Some("scanner_yyerror") }))', src\main.rs:60:9
** src\main.rs:60:9 = state.val.get().unwrap().execute(table_create_ref, &[]).unwrap();
As always, your kind efforts and support is appreciated, and we thank you for your involvement in the community.

Python "Serialize" not defined

can you help me figure out how to fix this issue or how to declare the variable? This is only part of my code but the section where the error is occurring.
def send_message(self, message, source = "Python Client", type = serialize.Message.INFO_MESSAGE):
md = Command.RTDE_TEXT_MESSAGE
fmt = '>B%dsB%dsB' % (len(message), len(source))
payload = struct.pack(fmt, len(message), message, len(source), source, type)
return self.__sendall(cmd, payload)
And here is the error I'm getting
File "..\rtde\rtde.py", line 187, in RTDE
def send_message(self, message, source = "Python Client", type = serialize.Message.INFO_MESSAGE):
NameError: name 'serialize' is not defined

Tornado on python3

My goal is to run http server on python3 using tornado (http://www.tornadoweb.org/).
I started with running example code found on their webpage:
import tornado.httpserver
import tornado.ioloop
from tornado import httputil
def handle_request(request):
message = "You requested %s\n" % request.uri
request.connection.write_headers(
httputil.ResponseStartLine('HTTP/1.1', 200, 'OK'),
{"Content-Length": str(len(message))})
request.connection.write(message)
request.connection.finish()
http_server = tornado.httpserver.HTTPServer(handle_request)
http_server.listen(8080)
tornado.ioloop.IOLoop.instance().start()
This code throws following exception when receiving any http request:
ERROR:tornado.application:Uncaught exception
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tornado/http1connection.py", line 234, in _read_message
delegate.finish()
File "/usr/local/lib/python3.4/dist-packages/tornado/httpserver.py", line 280, in finish
self.server.request_callback(self.request)
File "test.py", line 10, in handle_request
{"Content-Length": str(len(message))})
File "/usr/local/lib/python3.4/dist-packages/tornado/http1connection.py", line 367, in write_headers
lines.extend([utf8(n) + b": " + utf8(v) for n, v in headers.get_all()])
AttributeError: 'dict' object has no attribute 'get_all'
Whats wrong ? This is sample code, so it should work and problem is somewhere in my enviroment ?
I tried this both on latest Ubuntu and Win 7 and it gave me same error.
Thanks in advance
The documentation had a bug, fixed recently. For any version of Python, you can't pass a raw dict to write_headers. Instead you must wrap the dict in an HTTPHeaders object. For Python 3, the message must be a bytes instance. With both fixes:
def handle_request(request):
message = ("You requested %s\n" % request.uri).encode('ascii')
request.connection.write_headers(
httputil.ResponseStartLine('HTTP/1.1', 200, 'OK'),
httputil.HTTPHeaders({"Content-Length": str(len(message))}))
request.connection.write(message)
request.connection.finish()