import iris

# first, we connect to the %SYS namespace
conn = iris.connect('localhost:1972/%SYS','_SYSTEM',pwd,10,True)
irispy = iris.createIRIS(conn)

# here we switch to the USER namespace
newNameSpace = irispy.classMethodString('%SYSTEM.Process','SetNamespace','USER')

# now we can call the method from the new namespace
#print(irispy.classMethodInteger('DC.Unix','RoundPosixToSeconds',1154669852181849976))

conn.close()
#Include %sqlx
set newposix $$$sqlxPosixTimeEncode(+$p($$$sqlxPosixTimeDecode(posix),".",1))

Сheck:

for posix = 1154669852181849976, -6979664624441081856, 1406323805406846975 {

  set newposix $$$sqlxPosixTimeEncode(+$p($$$sqlxPosixTimeDecode(posix),".",1))

  write ##class(%PosixTime).LogicalToTimeStamp(posix),!,
        ##class(%PosixTime).LogicalToTimeStamp(newposix),!!
}

2025-05-27 12:06:15.003
2025-05-27 12:06:15
 
0001-01-01 00:00:00
0001-01-01 00:00:00
 
9999-12-31 23:59:59.999999
9999-12-31 23:59:59
 
source code of dc.observation_lab

The following query does not use iCode/iCodeText indexes (2025.2.CE):

select code_1_textcount(code_1_text)
  from dc.observation_lab
  group by code_1_text
  order by desc

PS: if possible, I would try to convert the text into a number in some way and index this number already, perhaps even with the bitmap type.

Here explained to us that this is not a bug, but a feature: <PROTECT> *Function not allowed in IRIS Native python

Starting from 2024.1 IRIS Native disallows routine invocations. Please use class methods instead.

For reference, these changes can be identified as DP-422635 and DP-424156.

PS: and yes, additional roles and resources like %Native_*/%All etc. no eliminate the <PROTECT> error. Checked on version 2025.2.CE

Very strange syntax:

But if we tried at once with a single statment with a select into (1 value) it fails

INSERT INTO Sample.YoungPeople (PASReligionCodevalues (SELECT internalPatientNumber FROM
Pennine_TIE_Clinicom_Link.PMISPECIALREGNCA where InternalPatientNumber=100)

See:

Yes.
Or you can immediately increase the logical size of the IRISTEMP to the desired value, for example:

%SYS>set status=##class(Config.Databases).Get("IRISTEMP",.props)
%SYS>set status=##class(SYS.Database).ModifyDatabase(props("Directory"),5*1024) ; 5Gb

In this case, you will immediately increase the size from 240Mb to 5Gb, bypassing many small expansions.

I simplified the code a bit for testing:

ROUTINE ztest23
Version()  quit 20250613
  ;
  ; do init^ztest22(100)  ; in one irissession
  ;
  ; in another irissession:
  ; do test^ztest23()
  ;

test(N=1E7) public {
  do runOne^ztest23("convertInRunFar",N,.dt1),
     runOne^ztest23("convertInBigMacFar",N,.dt2)
  write $fnumber(dt2-dt1*100/dt1,"",2)_"% difference",!
}

runOne(pLabel,N=1E7,&dtpublic ; kill dt do runOne^ztest23("convertInRunFar",1E7,.dt)
{
  if pLabel="convertInRunFar" {
    set comment="looping $$convertIn^ztestLib (far)"
  }else{
    set comment="%New^ztestBigMac, looping $$convertIn^ztestLib (far)"
    set convertName=$$%New^ztestBigMac()
  }
  
  set convertIny=$zconvert("Маленькая умная Коричневая Лиса прыгает через лежащую сонную Пятнистую Собаку","o","UTF8")
  
  set dt0=$zhorolog  for i=1:1:set convertInx=""
  set dt0=($zhorolog-dt0)
  set dt1=$zhorolog for i=1:1:set convertInx=$$convertIn^ztestLib(convertIny,"UTF8")
  set dt=($zhorolog-dt1-dt0)*1E6,dt=dt/N
  write pLabel,?30,$fnumber(dt,"",3),?45,comment,!
}

IRIS 2025.1 CE

I made 4 launches in a row - the result fluctuates greatly:

USER>set N=1E7 do runOne^ztest22("convertInRunFar",N,.fieldsset dt1=$get(fields("dt")) do runOne^ztest22("convertInBigMacFar",N,.fieldsset dt2=$get(fields("dt")) w $fn(dt2-dt1*100/dt1,"",2)_"% difference",!
convertInRunFar               0.473          looping $$convertIn^ztestLib (far)
convertInBigMacFar            0.478          %New^ztestBigMac, looping $$convertIn^ztestLib (far)
1.13% difference
 
USER>set N=1E7 do runOne^ztest22("convertInRunFar",N,.fieldsset dt1=$get(fields("dt")) do runOne^ztest22("convertInBigMacFar",N,.fieldsset dt2=$get(fields("dt")) w $fn(dt2-dt1*100/dt1,"",2)_"% difference",!
convertInRunFar               0.474          looping $$convertIn^ztestLib (far)
convertInBigMacFar            0.598          %New^ztestBigMac, looping $$convertIn^ztestLib (far)
25.99% difference
 
USER>set N=1E7 do runOne^ztest22("convertInRunFar",N,.fieldsset dt1=$get(fields("dt")) do runOne^ztest22("convertInBigMacFar",N,.fieldsset dt2=$get(fields("dt")) w $fn(dt2-dt1*100/dt1,"",2)_"% difference",!
convertInRunFar               0.461          looping $$convertIn^ztestLib (far)
convertInBigMacFar            0.597          %New^ztestBigMac, looping $$convertIn^ztestLib (far)
29.70% difference
 
USER>set N=1E7 do runOne^ztest22("convertInRunFar",N,.fieldsset dt1=$get(fields("dt")) do runOne^ztest22("convertInBigMacFar",N,.fieldsset dt2=$get(fields("dt")) w $fn(dt2-dt1*100/dt1,"",2)_"% difference",!
convertInRunFar               0.511          looping $$convertIn^ztestLib (far)
convertInBigMacFar            0.551          %New^ztestBigMac, looping $$convertIn^ztestLib (far)
7.88% difference
 
USER>

I'm afraid we can't do without the WRC.

See Zen Layout, Zen Style

Class dc.test Extends %ZEN.Component.page
{

XData Style
{
  <style type="text/css">
  #mss {
    width:200px;
    height:100px;
    overflow:auto;
    border:2px solid DeepPink;
    background-color: #E5E5E5;
  }

  a.multiSelectSetCaption {
    colorblue;
    font-familyVerdana;
    font-weightbold;
  }
</style>
}

XData Contents [ XMLNamespace "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
  <multiSelectSet
    id="mss"
    sql="
    select 1 id,'Apple' name
    union select 2,'Banana'
    union select 3,'Cherry'
    union select 4,'Peach'
    union select 5,'Peach'
    union select 6,'Cherry'
    union select 7,'Banana'
    union select 8,'Apple'"
  />
</page>
}

}
Class dc.test Extends %ZEN.Component.page
{

ClientMethod selectMulti() [ Language = javascript ]
{
  var values zenPage.GetValues()
  
  zenSetProp('mss','value',values);
}

ClassMethod GetValues() As %String ZenMethod ]
{
  ; here select data according to a certain condition
  &sql(
  select LIST(idinto :r
  from
    (select id,'Apple' name
    union
    select 2,'Banana'
    union
    select 3,'Cherry'
    union
    select 4,'Peach')
  where name['a'
  )
  quit ; return 2,4
}

ClientMethod saveMulti() [ Language = javascript ]
{
  var values zenGetProp('mss','value');
  zenPage.SaveValues(values);
}

ClassMethod SaveValues(values) [ ZenMethod ]
{
  set ^fruits=values
}

XData Contents [ XMLNamespace "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
  <button caption="Select All" onclick="zen('mss').selectAll()"/>
  <button caption="Select based on data from the database" onclick="zenPage.selectMulti();"/>
  <button caption="Save" onclick="zenPage.saveMulti();"/>
  <multiSelectSet
    id="mss"
    sql="select 1 id,'Apple' name union select 2,'Banana' union select 3,'Cherry' union select 4,'Peach'"
  />
</page>
}

}