Member since
05-05-2022
16
Posts
2
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
210 | 07-01-2022 02:55 AM |
08-01-2022
04:56 AM
Hello! Thank you for your comprehensive answer. But I sitll don't quite understand two things. 1. I am confused what does wildcard & do? Does it return only key or does it return the indices of elements as well, depending on level of &n? 2. Are [&4] and [&2] numbers like indices in arrays or strings like in dictionary "key":"value" pairs.? Thank you beforehand!
... View more
07-29-2022
03:55 AM
Hello! I've read this and this and this but explanations are pretty scarce. I understand what "&" means. But I can't wrap my head around what [&] means =\ Can someone please explain me what this [&] does applicable to this example? What exactly happening in lines? : "@1" : "outer[&4].inner[&2].t" ,
"@(3,eventTypeCode)" : "outer[&4].inner[&2].etc" JSON: {
"uID" : 1000358546 ,
"events" : [ {
"eventTypeCode" : "FEEDBACK" ,
"transports" : [ "PUSH" , "SMS" ]
} , {
"eventTypeCode" : "MARKETING" ,
"transports" : [ "PUSH" , "EMAIL" ]
} , {
"eventTypeCode" : "ORDER_STATUS" ,
"transports" : [ "SOC_VK" ]
}
]
} SPEC: [{
"operation" : "shift" ,
"spec" : {
"events" : {
"*" : {
"transports" : {
"*" : {
"*" : {
"@1" : "outer[&4].inner[&2].t" ,
"@(3,eventTypeCode)" : "outer[&4].inner[&2].etc"
}
}
}
}
},
"*" : "&"
}
}] RESULT: {
"uID" : 1000358546 ,
"outer" : [ {
"inner" : [ {
"t" : "PUSH" ,
"etc" : "FEEDBACK"
} , {
"t" : "SMS" ,
"etc" : "FEEDBACK"
} ]
} , {
"inner" : [ {
"t" : "PUSH" ,
"etc" : "MARKETING"
} , {
"t" : "EMAIL" ,
"etc" : "MARKETING"
} ]
} , {
"inner" : [ {
"t" : "SOC_VK" ,
"etc" : "ORDER_STATUS"
} ]
} ]
} Thanks beforehand!
... View more
Labels:
- Labels:
-
Apache NiFi
07-01-2022
03:17 AM
Hello! So I am trying to figure out how to work with the EnforceOrder processor. I have 200 flowfiles and every flowfile has attribute partition_number. Many flowfiles has the same filename. I wanna use EnforceOrder to merge them accroding to filename and partition_number attribute but non of the flowfiles ever go to success relationship queue. Here's my settings: What am I doing wrong?
... View more
Labels:
- Labels:
-
Apache NiFi
07-01-2022
02:55 AM
2 Kudos
I think you should refer to Ni-Fi cookbook That is pretty much THE only instruction for making scripts for ni fi
... View more
06-24-2022
02:25 AM
Hello! I am trying to read JSON body from a flowfile and write the length of a JSON array of elements to new flowfile attribute. But somehow I am getting aforementioned error all the time. Here is my script. from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
import json
#Define a subclass of StreamCallback for use in session.write()
class PyStreamCallback(StreamCallback):
def __init__(self):
pass
def process(self, inputStream, outputStream):
jsn = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
array = json.loads(jsn) # type: dict
i = 0
while i <= 1: # ищем вложенность второго уровня, чтобы посчитать кол-во элементов (записей в таблице)
root_key = list(array.keys())[0]
array = array[root_key]
i += 1
self.length = str(len(array))
def get_length_of_array(self):
return self.length
# end class
flowfile = session.get()
if(flowfile != None):
flowfile = session.write(flowfile, PyStreamCallback())
flowfile = session.putAttribute(flowfile, "length", PyStreamCallback().get_length_of_array())
session.transfer(flowFile, REL_SUCCESS) Can someone please explain me what am I doing wrong? Thank you beforehand!
... View more
Labels:
- Labels:
-
Apache NiFi
06-14-2022
12:33 AM
Hello! So I can't access NiFi UI because the server if probably down exactly because of amount of files that have been stuck at queue. So the question is how can I find out the size of the queue for the moment using may be logs or maybe there are some other ways to do so? Thank you beforehand!
... View more
Labels:
- Labels:
-
Apache NiFi
06-05-2022
08:27 AM
I've installed the last version of ni-fi and it solved all problems! Thank you!
... View more
06-04-2022
11:38 AM
Hello! Still same error unfortunately 😞
... View more
06-04-2022
12:22 AM
thank you again. kind sir!! I am trying to do this to increase a year, but ni-fi says there are no viable alternative at input '=' what am I doing wrong? end_next_year = datetime.strptime(current_date,'%Y-%m-%d').replace(year = datetime.strptime(current_date,'%Y-%m-%d').year + 1).strftime('%Y1231')
... View more
06-03-2022
04:44 PM
Hello! Thank you so much it worked! Can you please explain me how can I make date_filter with format %Y%m%d instead of %Y-%m-%d?
... View more
06-03-2022
02:36 PM
So I am trying to implement this script from datetime import datetime, timedelta, date
flowfile = session.get()
current_date= datetime.today().date()
if flowfile != None:
src_table_name = flowfile.getAttribute('src_table_name')
date_filter = str(current_date.replace(day =11))
if src_table_name in ['Income_project_BP', 'Plan_final_scenario', 'Plan_primary_scenario', 'ProductionCalendar', 'Subcontracting_BP']:
flowfile = session.putAttribute(flowfile, 'date_filter', date_filter)
session.transfer(flowfile, REL_SUCCESS)
else:
session.transfer(flowfile, REL_FAILURE) And I've tried a lot of different ways but when it comes to "replace" method I'm always getting this error. Same thing when I am trying to use "strftime" method What should I do? I really need this method. Thank you beforehand!
... View more
Labels:
- Labels:
-
Apache NiFi
05-31-2022
05:04 AM
Hello! So I am having dummy csv file: year, value 2001,А 2001,B 2002,A 2021,B 2022,A 2022,B Is there any way I can add attributes to this flowfile for every single value of 'year' column? I mean I need this flowfile to have year_2001 attribute with value 2001, year_2002 attribute with value 2002 and so on. I haven't found how to do it via ExtractText processor. And the second question if it is possible to do so, how can I loop through all of these attributes in the future?
... View more
- Tags:
- attributes
- NiFi
- value
Labels:
- Labels:
-
Apache NiFi
05-06-2022
01:13 AM
Hi! So I am very confused about how regular expressions and groups work in nifi. I read documentation and I saw that ExtractText processors always exctracts more attributes than needed somehow. So I have this file with the line like this 9999, text And I wrote regular expression to extract value 9999 for attribute call number. (\d{4}) But instead of one attribute number I am getting number0, number and number1 attributes. Can someone please explain me why is this happening, because documentation explanation is quite complex really. Thank you beforehand!
... View more
Labels:
- Labels:
-
Apache NiFi
05-05-2022
11:04 PM
Hello! tank you for such a detailed answer. Will it work if I have a .txt file as a source? Or should I convert it to csv somethow first?
... View more
05-05-2022
08:20 AM
Hello! Sorry for my english. I am completely new to nifi and I am learning SplitText processor. So here's the case. I have the comma separated txt file, something like this: KeyWord, SomeInformation <---1st line is schema. KeyWord1, "information" KeyWord2, "information" KeyWord1, "another information" KeyWord2, "another information" and so on. So the question is how can I split this file on a few files based on KeyWord? So the every line with KeyWord1 go to one file, every line with KeyWord2 go to another file and so on? Thank you beforehand!
... View more
Labels:
- Labels:
-
Apache NiFi