I'm getting the following error after generating a schema and clicking on build, could this be due to having underscores and dashes in the table name? - cube.js

Compiling schema:
{"version":"default_schema_version_78dca52738894dbb23e7069f2e88ae73"}
Internal Server Error: {"authInfo":{"iat":1570115494,"exp":1570201894}}
Error: Compile errors:
test_1-stats cube: child "name" fails because ["name" with value "test_1-stats" fails to match the identifier pattern]
at ErrorReporter.throwIfAny (/home/ec2-user/hello-world/node_modules/#cubejs-backend/schema-compiler/compiler/DataSchemaCompiler.js:42:13)
at DataSchemaCompiler.throwIfAnyErrors (/home/ec2-user/hello-world/node_modules/#cubejs-backend/schema-compiler/compiler/DataSchemaCompiler.js:168:23)
at repository.dataSchemaFiles.then.then (/home/ec2-user/hello-world/node_modules/#cubejs-backend/schema-compiler/compiler/DataSchemaCompiler.js:100:14)

The answer is yes.
The cube.js schema does not allow dashes in names.
Remove any dashes in the database / table names to fix this issue.

There are certain rules to follow for a cube and cube member names. You can use only 0-9, _, and letter characters when naming a cube or a cube member. Names should always start with a letter.
https://cube.dev/docs/cube#naming

Related

Enabling Elasticsearch index names with illegal characters

I am trying to create elasticsearch indexes with strings like xxx/yyy and xxx yyy but these are not permitted because they contain illegal characters (/ and ). These names are largely user created and out of my control so changing the names for the sake of fitting into the requirements of elasticsearch is not really an option.
This is the exact error message:
[Error: InvalidIndexNameException[[XXX\%FFZZZ] Invalid index name [XXX\%FFZZZ], must not contain the following characters [\, /, *, ?, ", <, >, |, , ,]]]
Anyways, I've tried URL encoding the strings, but that doesn't work because those include capital letters which are not permitted and backslash escaping is out of the question because it is in the list of illegal characters.
Is there a conventional solution to this problem, or do I have to come up with some sketchy serialization and/or hashing scheme to solve this?
Hmm, letting users have the control on such things like index name is asking for troubles :)
But if you're willing to pursue that route, what I suggest is simply to remove any character that is not alphanumeric and lowercase the result in the process.
In PHP that would be:
$index = preg_replace("/[^a-z0-9]+/i", "", $index);
In Java:
index = index.replace("/[^a-z0-9]+/i", "");
In Javascript:
index = index.replace(/[^a-z0-9]+/i, "");
Please do not allow users to define the index name. You can try to filter out illegal characters, but your regexp might have an issue, and you might run into trouble later.
Also users might not understand why they create problems if one usere uses My_Index and writes stuff in and the next user trying to access yndex accesses the same index.
BTW: The regexp given above is more strict than the list of legal characters asks for. For example _ is legal (but not at the beginning of the name), if you wanted to create a regexp that allows everything that is legal by ES standards, your regexp becomes more complicated and more error prone.

How to reproduce MATCHES in NSPredicate to query Realm?

I have a query using NSPredicate that takes regular expression and matches to paths:
let predicate = NSPredicate(format: "path MATCHES '/test/([^/]*[^/])$'")
which matches everything inside folder test but excludes all subfolders of folders in test, like this:
/test/abc -> yes
/test/abc/def -> no
The problem is, that I can't use the MATCH keyword of NSPredicate in Realm.io. How can I reproduce this query so it works in Realm?
Adding the exception for completeness:
*** Terminating app due to uncaught exception 'Invalid operator type', reason: 'Operator type 6 not supported for string type'
So for now I have solved the problem like this (modifying the model, which I wanted to avoid):
I store only the path to the parent, not the full one along with the name. The name gets stored in a different field (to get full path I stitch the two strings together)
Instead of matching the regular expression I use NSPredicate(format: "path ==[c] %#", "/test/") to get the contents of the folder test.
Why am I not totally happy with this solution:
I wanted to avoid separating the field fullPath into two fields because when file gets renamed + moved, it's only one operation - rewrite the fullPath in the database. It may seem like a minor problem, but having only one place of responsibility gave it a bit more robustness, because files are moved and renamed all the time in the environment of the app.
Joe from Realm here. Currently regex isn't supported in Realm queries with MATCH, you will need to do this manually. I would build an NSArray and use a filter predicate on that. We are aware of this and tracking all unsupported predicates here

Regex expression for grabbing certain keyword and combine them together

I have the following text and i would like to grab the keyword "ATTEMPT TO ACCESS DATABASE" and "was denied", and combine these two together. However, there are some user and path name information in between these two keywords, and this makes it difficult for me to capture the thing i want, as i'm still not yet a regex expert. XD
<182>Mar 27 09:38:55 4.3.2.1 [5439570:00311-46004] 03/11/2015 14:13:05
ATTEMPT TO ACCESS DATABASE mail/abc.nsf by USER was denied
Is there a single regex expression that can help me to fulfill my requirement? Would greatly appreciate for all the help!
Have a look at the following regex:
(ATTEMPT\s+TO\s+ACCESS\s+DATABASE\s+)(\S+)\s+by\s+([\w.-]+)\s+(was\s+denied)
Ouput is:
MATCH 1
1. [71-98] `ATTEMPT TO ACCESS DATABASE `
2. [98-110] `mail/abc.nsf`
3. [114-118] `USER`
4. [119-129] `was denied`
So, you can combine Group 1 and 4 to get ATTEMPT TO ACCESS DATABASE was denied (in any case due to i option), and Group 2 will contain the path name, and Group 3 will hold the user name.

Yaml-cpp parsing doesn't work space is missing after colon

I have encountered problem in yaml-cpp parser. When I try to load following definition:
DsUniversity:
university_typ: {type: enum, values:[Fachhochschule, Universitat, Berufsakademie]}
students_at_university: {type: string(50)}
I'm getting following error:
Error: yaml-cpp: error at line 2, column 39: end of map flow not found
I tried to verify yaml validity on http://yaml-online-parser.appspot.com/ and http://yamllint.com/ and both services reports yaml as valid.
Problem is caused by missing space after "values:" definition. When yaml is updated to following format:
DsUniversity:
university_typ: {type: enum, values: [Fachhochschule, Universitat, Berufsakademie]}
students_at_university: {type: string(50)}
everything works as expected.
Is there any way how to configure/update/fix yaml-cpp parser to proceed also yamls with missing space after colon?
Added:
It seems that problem is caused by requirement for empty char as separator. When I simplified testing snippet to
DsUniversity:[Fachhochschule, Universitat, Berufsakademie]
yaml-cpp parser reads it as one scalar value "DsUniversity:[Fachhochschule, Universitat, Berufsakademie]". When empty char is added after colon, yaml-cpp correctly loads element with sequence.
yaml-cpp is correct here, and those online validators are incorrect. From the YAML 1.2 spec:
7.4.2. Flow Mappings
Normally, YAML insists the “:” mapping value indicator be separated from the value by white space. A benefit of this restriction is that the “:” character can be used inside plain scalars, as long as it is not followed by white space. This allows for unquoted URLs and timestamps. It is also a potential source for confusion as “a:1” is a plain scalar and not a key: value pair.
...
To ensure JSON compatibility, if a key inside a flow mapping is JSON-like, YAML allows the following value to be specified adjacent to the “:”. This causes no ambiguity, as all JSON-like keys are surrounded by indicators. However, as this greatly reduces readability, YAML processors should separate the value from the “:” on output, even in this case.
In your example, you're in a flow mapping (meaning a map surrounded by {}), but your key is not JSON-like: you just have a plain scalar (values is unquoted). To be JSON-like, the key needs to be either single- or double-quoted, or it can be a nested flow sequence or map itself.
In your simplified example,
DsUniversity:[Fachhochschule, Universitat, Berufsakademie]
both yaml-cpp and the online validators parse this correctly as a single scalar - in order to be a map, as you intend, you're required a space after the :.
Why does YAML require that space?
In the simple plain scalar case:
a:b
could be ambiguous: it could be read as either a scalar a:b, or a map {a: b}. YAML chooses to read this as a scalar so that URLs can be easily embedded in YAML without quoting:
http://stackoverflow.com
is a scalar (like you'd expect), not a map {http: //stackoverflow.com}!
In a flow context, there's one case where this isn't ambiguous: when the key is quoted, e.g.:
{"a":b}
This is called JSON-like because it's similar to JSON, which requires quotes around all scalars. In this case, YAML knows that the key ends at the end-quote, and so it can be sure that the value starts immediately.
This behavior is explicitly allowed because JSON itself allows things like
{"a":"b"}
Since YAML 1.2 is a strict superset of JSON, this must be legal in YAML.
I think it would be beneficial to parse scalar/keys differently immediately inside a flow map{, if you agree, vote here please.
https://github.com/yaml/yaml-spec/issues/267

PowerShell isolating parts of strings

I have no experience with regular expressions and would love some help and suggestions on a possible solution to deleting parts of file names contained in a csv file.
Problem:
A list of exported file names contains a random unique identifier that I need isolated. The unique identifier has no predictable pattern, however the aspects which need removing do. Each file name ends with one of the following variations:
V, -V, or %20V followed by a random number sequence with possible spaces, additional "-","" and ending with .PDF
examples:
GTD-LVOE-43-0021 V10 0.PDF
GTD-LVOE-43-0021-V34-2.PDF
GTD-LVOE-43-0021_V02_9.PDF
GTD-LVOE-43-0021 V49.9.PDF
Solution:
My plan was to write a script to select of the first occurrence of a V from the end of the string and then delete it and everything to the right of it. Then the file names can be cleaned up by deleting any "-" or "_" and white space that occurs at the end of a string.
Question:
How can I do this with a regular expression and is my line of thinking even close to the right approach to solving this?
REGEX: [\s\-_]V.*?\.PDF
Might do the trick. You'd still need to replace away any leading - and _, but it should get you down the path, hopefully.
This would read as follows..
start with a whitespace, - OR _ followed by a V. Then take everything until you get to the first .PDF