diff --git a/build.gradle.kts b/build.gradle.kts index 186662aefd..c2890ce0b4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -189,6 +189,12 @@ allprojects { options.release.set(8) } } + tasks.withType { + compilerOptions { + // enables support for kotlin.time.Instant as kotlinx.datetime.Instant was deprecated + optIn.add("kotlin.time.ExperimentalTime") + } + } // Attempts to configure ktlint for each sub-project that uses the plugin afterEvaluate { diff --git a/core/api/core.api b/core/api/core.api index 6776e208fd..de0fc7a77a 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1474,6 +1474,8 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static final fun convertToBooleanFromT (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToByte (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToByteFromT (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToDeprecatedInstant (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToDeprecatedInstantFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToDouble (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToDoubleFromString (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Ljava/util/Locale;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToDoubleFromString (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Ljava/util/Locale;Ljava/util/Set;Ljava/lang/Boolean;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; @@ -1507,16 +1509,20 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static final fun convertToLocalDateTime (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToLocalDateTime (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static synthetic fun convertToLocalDateTime$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; - public static final fun convertToLocalDateTimeFromInstant (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; - public static synthetic fun convertToLocalDateTimeFromInstant$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; - public static final fun convertToLocalDateTimeFromInstantNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; - public static synthetic fun convertToLocalDateTimeFromInstantNullable$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToLocalDateTimeFromDeprecatedInstant (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static synthetic fun convertToLocalDateTimeFromDeprecatedInstant$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToLocalDateTimeFromDeprecatedInstantNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static synthetic fun convertToLocalDateTimeFromDeprecatedInstantNullable$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToLocalDateTimeFromInt (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static synthetic fun convertToLocalDateTimeFromInt$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToLocalDateTimeFromIntNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static synthetic fun convertToLocalDateTimeFromIntNullable$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToLocalDateTimeFromLong (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static synthetic fun convertToLocalDateTimeFromLong$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToLocalDateTimeFromStdlibInstant (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static synthetic fun convertToLocalDateTimeFromStdlibInstant$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToLocalDateTimeFromStdlibInstantNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static synthetic fun convertToLocalDateTimeFromStdlibInstantNullable$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToLocalDateTimeFromString (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Ljava/lang/String;Ljava/util/Locale;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static synthetic fun convertToLocalDateTimeFromString$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Ljava/lang/String;Ljava/util/Locale;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToLocalDateTimeFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Ljava/lang/String;Ljava/util/Locale;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; @@ -1540,6 +1546,10 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static final fun convertToLongFromT (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToShort (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToShortFromT (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToStdlibInstant (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToStdlibInstantFromDeprecatedInstant (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToStdlibInstantFromDeprecatedInstantNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; + public static final fun convertToStdlibInstantFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToString (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToStringFromT (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static final fun convertToURL (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; @@ -1558,6 +1568,8 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static final fun toDataFrames (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Z)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static synthetic fun toDataFrames$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;ZILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; public static synthetic fun toDataFrames$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;ZILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toDeprecatedInstantFromString (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toDeprecatedInstantFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toDouble (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toDoubleTAny (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toFloat (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; @@ -1592,10 +1604,10 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static synthetic fun toLocalDateTimeFromString$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Ljava/lang/String;Ljava/util/Locale;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLocalDateTimeFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Ljava/lang/String;Ljava/util/Locale;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static synthetic fun toLocalDateTimeFromStringNullable$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Ljava/lang/String;Ljava/util/Locale;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; - public static final fun toLocalDateTimeFromTInstant (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; - public static synthetic fun toLocalDateTimeFromTInstant$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; - public static final fun toLocalDateTimeFromTInstantNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; - public static synthetic fun toLocalDateTimeFromTInstantNullable$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toLocalDateTimeFromTDeprecatedInstant (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static synthetic fun toLocalDateTimeFromTDeprecatedInstant$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toLocalDateTimeFromTDeprecatedInstantNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static synthetic fun toLocalDateTimeFromTDeprecatedInstantNullable$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLocalDateTimeFromTInt (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static synthetic fun toLocalDateTimeFromTInt$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLocalDateTimeFromTIntNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; @@ -1604,6 +1616,10 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static synthetic fun toLocalDateTimeFromTLong$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLocalDateTimeFromTLongNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static synthetic fun toLocalDateTimeFromTLongNullable$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toLocalDateTimeFromTStdlibInstant (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static synthetic fun toLocalDateTimeFromTStdlibInstant$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toLocalDateTimeFromTStdlibInstantNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static synthetic fun toLocalDateTimeFromTStdlibInstantNullable$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLocalTime (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLocalTimeFromString (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Ljava/lang/String;Ljava/util/Locale;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static synthetic fun toLocalTimeFromString$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Ljava/lang/String;Ljava/util/Locale;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; @@ -1619,6 +1635,10 @@ public final class org/jetbrains/kotlinx/dataframe/api/ConvertKt { public static synthetic fun toLocalTimeFromTLongNullable$default (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlinx/datetime/TimeZone;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLong (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toLongTAny (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toStdlibInstantFromDeprecatedInstant (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toStdlibInstantFromDeprecatedInstantNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toStdlibInstantFromString (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun toStdlibInstantFromStringNullable (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toStr (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toStrTAny (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun toURLFromString (Lorg/jetbrains/kotlinx/dataframe/api/Convert;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; @@ -2427,11 +2447,13 @@ public abstract interface class org/jetbrains/kotlinx/dataframe/api/GlobalParser public abstract fun addSkipType (Lkotlin/reflect/KType;)V public abstract fun getLocale ()Ljava/util/Locale; public abstract fun getNulls ()Ljava/util/Set; + public abstract fun getParseExperimentalInstant ()Z public abstract fun getParseExperimentalUuid ()Z public abstract fun getSkipTypes ()Ljava/util/Set; public abstract fun getUseFastDoubleParser ()Z public abstract fun resetToDefault ()V public abstract fun setLocale (Ljava/util/Locale;)V + public abstract fun setParseExperimentalInstant (Z)V public abstract fun setParseExperimentalUuid (Z)V public abstract fun setUseFastDoubleParser (Z)V } @@ -3535,19 +3557,20 @@ public final class org/jetbrains/kotlinx/dataframe/api/ParserOptions { public synthetic fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;)V public synthetic fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;)V - public synthetic fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)V + public synthetic fun (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final synthetic fun copy (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; public final synthetic fun copy (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; - public final fun copy (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; + public final fun copy (Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; public static synthetic fun copy$default (Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions;Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; public static synthetic fun copy$default (Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions;Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; - public static synthetic fun copy$default (Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions;Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; + public static synthetic fun copy$default (Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions;Ljava/util/Locale;Ljava/time/format/DateTimeFormatter;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/api/ParserOptions; public fun equals (Ljava/lang/Object;)Z public final fun getDateTimeFormatter ()Ljava/time/format/DateTimeFormatter; public final fun getDateTimePattern ()Ljava/lang/String; public final fun getLocale ()Ljava/util/Locale; public final fun getNullStrings ()Ljava/util/Set; + public final fun getParseExperimentalInstant ()Ljava/lang/Boolean; public final fun getParseExperimentalUuid ()Ljava/lang/Boolean; public final fun getSkipTypes ()Ljava/util/Set; public final fun getUseFastDoubleParser ()Ljava/lang/Boolean; @@ -6012,6 +6035,7 @@ public final class org/jetbrains/kotlinx/dataframe/io/ColType : java/lang/Enum { public static final field Char Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field Companion Lorg/jetbrains/kotlinx/dataframe/io/ColType$Companion; public static final field DEFAULT Ljava/lang/String; + public static final field DeprecatedInstant Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field Double Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field Duration Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field Instant Lorg/jetbrains/kotlinx/dataframe/io/ColType; @@ -6022,6 +6046,7 @@ public final class org/jetbrains/kotlinx/dataframe/io/ColType : java/lang/Enum { public static final field LocalDateTime Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field LocalTime Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field Long Lorg/jetbrains/kotlinx/dataframe/io/ColType; + public static final field StdlibInstant Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field String Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static final field Url Lorg/jetbrains/kotlinx/dataframe/io/ColType; public static fun getEntries ()Lkotlin/enums/EnumEntries; diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt index 8467cc7c1e..e90e3e4e19 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt @@ -1,6 +1,5 @@ package org.jetbrains.kotlinx.dataframe.api -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -22,6 +21,7 @@ import org.jetbrains.kotlinx.dataframe.annotations.Converter import org.jetbrains.kotlinx.dataframe.annotations.HasSchema import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine +import org.jetbrains.kotlinx.dataframe.api.convertToDeprecatedInstant import org.jetbrains.kotlinx.dataframe.columns.BaseColumn import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -41,10 +41,18 @@ import org.jetbrains.kotlinx.dataframe.impl.headPlusArray import org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser import org.jetbrains.kotlinx.dataframe.io.toDataFrame import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_DEPRECATED_INSTANT +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_DEPRECATED_INSTANT_REPLACE +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_INSTANT +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_INSTANT_REPLACE import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_REPLACE import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_URL import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_URL_REPLACE import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API +import org.jetbrains.kotlinx.dataframe.util.TO_DEPRECATED_INSTANT +import org.jetbrains.kotlinx.dataframe.util.TO_DEPRECATED_INSTANT_REPLACE +import org.jetbrains.kotlinx.dataframe.util.TO_INSTANT +import org.jetbrains.kotlinx.dataframe.util.TO_INSTANT_REPLACE import org.jetbrains.kotlinx.dataframe.util.TO_URL import org.jetbrains.kotlinx.dataframe.util.TO_URL_REPLACE import java.math.BigDecimal @@ -56,6 +64,8 @@ import kotlin.reflect.KProperty import kotlin.reflect.KType import kotlin.reflect.full.isSubtypeOf import kotlin.reflect.typeOf +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant /** * See also [parse] — a specialized form of the [convert] operation that parses [String] columns @@ -176,7 +186,8 @@ internal interface ConvertDocs { * * [Byte], [Short], [Char]; * * [Int], [Long], [Float], [Double]; * * [BigDecimal], [BigInteger]; - * * [LocalDateTime], [LocalDate], [LocalTime], [Instant] ( (kotlinx.datetime and [java.time]), + * * [LocalDateTime], [LocalDate], [LocalTime], + * `Instant` ([kotlinx.datetime][DeprecatedInstant], [kotlin.time][StdlibInstant], and [java.time]), * * [URL], [IMG], [IFRAME]. */ interface SupportedTypes @@ -461,7 +472,8 @@ public inline fun Convert.notNull( * - [asFrame][Convert.asFrame] – converts [column groups][ColumnGroup] as a [DataFrame] with the given expression. * - [toStr], [toInt], [toLong], [toDouble], [toFloat], [toBigDecimal], * [toBigInteger], [toBoolean] – convert to standard types. - * - [toLocalDateTime], [toLocalDate], [toLocalTime], [toInstant] – convert to kotlinx.datetime types. + * - [toLocalDateTime], [toLocalDate], [toLocalTime] – convert to kotlinx.datetime types. + * - [toInstant] (temporarily deprecated), [toStdlibInstant], [toDeprecatedInstant] – convert to `Instant` * - [toUrl], [toIFrame], [toImg] – convert to special types. * - [toDataFrames] – converts a column of lists into separate DataFrames. * @@ -1189,22 +1201,117 @@ public fun Convert.toUrl(): DataFrame = asColumn { it.convertT // region toInstant /** - * Converts values in this [String] column to [Instant]. + * __Deprecated__: * - * @return A new [DataColumn] with the [Instant] values. + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] or use [convertToDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. */ -public fun DataColumn.convertToInstant(): DataColumn = map { Instant.parse(it) } +@Deprecated( + message = CONVERT_TO_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_INSTANT_REPLACE), + level = DeprecationLevel.ERROR, +) +public fun DataColumn.convertToInstant(): DataColumn = map { DeprecatedInstant.parse(it) } /** - * Converts values in this [String] column to [Instant]. Preserves null values. + * __Deprecated__: * - * @return A new [DataColumn] with the [Instant] nullable values. + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] or use [convertToDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. */ @JvmName("convertToInstantFromStringNullable") -public fun DataColumn.convertToInstant(): DataColumn = map { it?.let { Instant.parse(it) } } +@Deprecated( + message = CONVERT_TO_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_INSTANT_REPLACE), + level = DeprecationLevel.ERROR, +) +public fun DataColumn.convertToInstant(): DataColumn = + map { it?.let { DeprecatedInstant.parse(it) } } /** - * Converts values in the [String] columns previously selected with [convert] to the [Instant], + * Converts values in this [String] column to the deprecated [kotlinx.datetime.Instant]. + * + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataColumn] with the [kotlinx.datetime.Instant] values. + */ +@Deprecated( + message = CONVERT_TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +public fun DataColumn.convertToDeprecatedInstant(): DataColumn = + map { DeprecatedInstant.parse(it) } + +/** + * Converts values in this [String] column to the deprecated [kotlinx.datetime.Instant]. Preserves null values. + * + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataColumn] with the nullable [kotlinx.datetime.Instant] values. + */ +@Deprecated( + message = CONVERT_TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +@JvmName("convertToDeprecatedInstantFromStringNullable") +public fun DataColumn.convertToDeprecatedInstant(): DataColumn = + map { it?.let { DeprecatedInstant.parse(it) } } + +/** + * Converts values in this [String] column to [kotlin.time.Instant]. + * + * This function will be renamed to `.convertToInstant()` in 1.1. + * + * @return A new [DataColumn] with the [kotlin.time.Instant] values. + */ +public fun DataColumn.convertToStdlibInstant(): DataColumn = map { StdlibInstant.parse(it) } + +/** + * Converts values in this [String] column to [kotlin.time.Instant]. Preserves null values. + * + * This function will be renamed to `.convertToInstant()` in 1.1. + * + * @return A new [DataColumn] with the [kotlin.time.Instant] nullable values. + */ +@JvmName("convertToStdlibInstantFromStringNullable") +public fun DataColumn.convertToStdlibInstant(): DataColumn = + map { it?.let { StdlibInstant.parse(it) } } + +/** + * __Deprecated__: + * + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [toStdlibInstant] or use [toDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. + */ + +@JvmName("toInstantFromStringNullable") +@Refine +@Converter(DeprecatedInstant::class, nullable = true) +@Interpretable("ToSpecificType") +@Deprecated(message = TO_INSTANT, replaceWith = ReplaceWith(TO_INSTANT_REPLACE), level = DeprecationLevel.ERROR) +public fun Convert.toInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } + +/** + * __Deprecated__: + * + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [toStdlibInstant] or use [toDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. + */ +@JvmName("toInstantFromString") +@Refine +@Converter(DeprecatedInstant::class, nullable = false) +@Interpretable("ToSpecificType") +@Deprecated(message = TO_INSTANT, replaceWith = ReplaceWith(TO_INSTANT_REPLACE), level = DeprecationLevel.ERROR) +public fun Convert.toInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } + +/** + * Converts values in the [String] columns previously selected with [convert] to [kotlinx.datetime.Instant], * preserving their original names and positions within the [DataFrame]. * Preserves null values. * @@ -1215,16 +1322,23 @@ public fun DataColumn.convertToInstant(): DataColumn = map { * df.convert { timestamp }.toInstant() * ``` * - * @return A new [DataFrame] with the values converted to [Instant]. + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataFrame] with the values converted to [kotlinx.datetime.Instant]. */ -@JvmName("toInstantFromStringNullable") +@JvmName("toDeprecatedInstantFromStringNullable") @Refine -@Converter(Instant::class, nullable = true) +@Converter(DeprecatedInstant::class, nullable = true) @Interpretable("ToSpecificType") -public fun Convert.toInstant(): DataFrame = asColumn { it.convertToInstant() } +@Deprecated( + message = TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +public fun Convert.toDeprecatedInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } /** - * Converts values in the [String] columns previously selected with [convert] to the [Instant], + * Converts values in the [String] columns previously selected with [convert] to [kotlinx.datetime.Instant], * preserving their original names and positions within the [DataFrame]. * * For more information: [See `convert` on the documentation website.](https://kotlin.github.io/dataframe/convert.html) @@ -1234,13 +1348,63 @@ public fun Convert.toInstant(): DataFrame = asColumn { it.con * df.convert { timestamp }.toInstant() * ``` * - * @return A new [DataFrame] with the values converted to [Instant]. + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataFrame] with the values converted to [kotlinx.datetime.Instant]. */ -@JvmName("toInstantFromString") +@JvmName("toDeprecatedInstantFromString") +@Refine +@Converter(DeprecatedInstant::class, nullable = false) +@Interpretable("ToSpecificType") +@Deprecated( + message = TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +public fun Convert.toDeprecatedInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } + +/** + * Converts values in the [String] columns previously selected with [convert] to the [StdlibInstant], + * preserving their original names and positions within the [DataFrame]. + * Preserves null values. + * + * For more information: [See `convert` on the documentation website.](https://kotlin.github.io/dataframe/convert.html) + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toInstant() + * ``` + * + * This function will be renamed to `.toInstant()` in 1.1. + * + * @return A new [DataFrame] with the values converted to [StdlibInstant]. + */ +@JvmName("toStdlibInstantFromStringNullable") @Refine -@Converter(Instant::class, nullable = false) +@Converter(StdlibInstant::class, nullable = true) @Interpretable("ToSpecificType") -public fun Convert.toInstant(): DataFrame = asColumn { it.convertToInstant() } +public fun Convert.toStdlibInstant(): DataFrame = asColumn { it.convertToStdlibInstant() } + +/** + * Converts values in the [String] columns previously selected with [convert] to the [StdlibInstant], + * preserving their original names and positions within the [DataFrame]. + * + * For more information: [See `convert` on the documentation website.](https://kotlin.github.io/dataframe/convert.html) + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toInstant() + * ``` + * + * This function will be renamed to `.toInstant()` in 1.1. + * + * @return A new [DataFrame] with the values converted to [StdlibInstant]. + */ +@JvmName("toStdlibInstantFromString") +@Refine +@Converter(StdlibInstant::class, nullable = false) +@Interpretable("ToSpecificType") +public fun Convert.toStdlibInstant(): DataFrame = asColumn { it.convertToStdlibInstant() } // endregion @@ -1742,26 +1906,52 @@ public fun DataColumn.convertToLocalDateTime(zone: TimeZone = defaultTime map { it?.toLocalDateTime(zone) } /** - * Converts values in this [Instant] column to [LocalDateTime]. + * Converts values in this [kotlinx.datetime.Instant] column to [LocalDateTime]. * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a date-time. + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a date-time. * Defaults to the system current time zone. * @return A new [DataColumn] with the [LocalDateTime] values. */ -@JvmName("convertToLocalDateTimeFromInstant") -public fun DataColumn.convertToLocalDateTime(zone: TimeZone = defaultTimeZone): DataColumn = - map { it.toLocalDateTime(zone) } +@JvmName("convertToLocalDateTimeFromDeprecatedInstant") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it.toLocalDateTime(zone) } /** - * Converts values in this [Instant] column to [LocalDateTime]. Preserves null values. + * Converts values in this [kotlinx.datetime.Instant] column to [LocalDateTime]. Preserves null values. * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a date-time. + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a date-time. * Defaults to the system current time zone. * @return A new [DataColumn] with the [LocalDateTime] nullable values. */ -@JvmName("convertToLocalDateTimeFromInstantNullable") -public fun DataColumn.convertToLocalDateTime(zone: TimeZone = defaultTimeZone): DataColumn = - map { it?.toLocalDateTime(zone) } +@JvmName("convertToLocalDateTimeFromDeprecatedInstantNullable") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it?.toLocalDateTime(zone) } + +/** + * Converts values in this [kotlin.time.Instant] column to [LocalDateTime]. + * + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a date-time. + * Defaults to the system current time zone. + * @return A new [DataColumn] with the [LocalDateTime] values. + */ +@JvmName("convertToLocalDateTimeFromStdlibInstant") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it.toLocalDateTime(zone) } + +/** + * Converts values in this [kotlin.time.Instant] column to [LocalDateTime]. Preserves null values. + * + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a date-time. + * Defaults to the system current time zone. + * @return A new [DataColumn] with the [LocalDateTime] nullable values. + */ +@JvmName("convertToLocalDateTimeFromStdlibInstantNullable") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it?.toLocalDateTime(zone) } /** * Converts values in this [Int] column to [LocalDateTime]. @@ -1868,7 +2058,50 @@ public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone asColumn { it.convertToLocalDateTime(zone) } /** - * Converts values in the [Instant] columns previously selected with [convert] to the [LocalDateTime], + * Converts values in the [kotlinx.datetime.Instant] columns previously selected with [convert] to the [LocalDateTime], + * preserving their original names and positions within the [DataFrame]. + * Preserves null values. + * + * For more information: [See `convert` on the documentation website.](https://kotlin.github.io/dataframe/convert.html) + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toLocalDateTime() + * ``` + * + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a time. Defaults to the system current time zone. + * @return A new [DataFrame] with the values converted to [LocalDateTime]. + */ +@JvmName("toLocalDateTimeFromTDeprecatedInstantNullable") +@Refine +@Converter(LocalDateTime::class, nullable = true) +@Interpretable("ToSpecificTypeZone") +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = + asColumn { it.convertToLocalDateTime(zone) } + +/** + * Converts values in the [kotlinx.datetime.Instant] columns previously selected with [convert] to the [LocalDateTime], + * preserving their original names and positions within the [DataFrame]. + * + * For more information: [See `convert` on the documentation website.](https://kotlin.github.io/dataframe/convert.html) + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toLocalDateTime() + * ``` + * + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a time. Defaults to the system current time zone. + * @return A new [DataFrame] with the values converted to [LocalDateTime]. + */ +@JvmName("toLocalDateTimeFromTDeprecatedInstant") +@Refine +@Converter(LocalDateTime::class, nullable = false) +@Interpretable("ToSpecificTypeZone") +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = + asColumn { it.convertToLocalDateTime(zone) } + +/** + * Converts values in the [kotlin.time.Instant] columns previously selected with [convert] to the [LocalDateTime], * preserving their original names and positions within the [DataFrame]. * Preserves null values. * @@ -1879,18 +2112,18 @@ public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone * df.convert { timestamp }.toLocalDateTime() * ``` * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a time. Defaults to the system current time zone. + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a time. Defaults to the system current time zone. * @return A new [DataFrame] with the values converted to [LocalDateTime]. */ -@JvmName("toLocalDateTimeFromTInstantNullable") +@JvmName("toLocalDateTimeFromTStdlibInstantNullable") @Refine @Converter(LocalDateTime::class, nullable = true) @Interpretable("ToSpecificTypeZone") -public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = asColumn { it.convertToLocalDateTime(zone) } /** - * Converts values in the [Instant] columns previously selected with [convert] to the [LocalDateTime], + * Converts values in the [kotlin.time.Instant] columns previously selected with [convert] to the [LocalDateTime], * preserving their original names and positions within the [DataFrame]. * * For more information: [See `convert` on the documentation website.](https://kotlin.github.io/dataframe/convert.html) @@ -1900,14 +2133,14 @@ public fun Convert.toLocalDateTime(zone: TimeZone = defaultTime * df.convert { timestamp }.toLocalDateTime() * ``` * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a time. Defaults to the system current time zone. + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a time. Defaults to the system current time zone. * @return A new [DataFrame] with the values converted to [LocalDateTime]. */ -@JvmName("toLocalDateTimeFromTInstant") +@JvmName("toLocalDateTimeFromTStdlibInstant") @Refine @Converter(LocalDateTime::class, nullable = false) @Interpretable("ToSpecificTypeZone") -public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = asColumn { it.convertToLocalDateTime(zone) } /** diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt index 5d379ce34e..3fa7142898 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt @@ -85,6 +85,16 @@ public interface GlobalParserOptions { * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments. */ public var parseExperimentalUuid: Boolean + + /** + * Whether to allow parsing to the experimental [kotlin.time.Instant] type. + * By default, this is false and instants are recognized as the deprecated [kotlinx.datetime.Instant] type (#1350). + * + * NOTE: Interacting with an [Instant][kotlin.time.Instant] in your code might require + * `@`[OptIn][OptIn]`(`[ExperimentalTime][kotlin.time.ExperimentalTime]`::class)`. + * In notebooks, add `-opt-in=kotlin.time.ExperimentalTime` to the compiler arguments. + */ + public var parseExperimentalInstant: Boolean } /** @@ -118,6 +128,11 @@ public interface GlobalParserOptions { * NOTE: Interacting with a [Uuid][Uuid] in your code might require * `@`[OptIn][OptIn]`(`[ExperimentalUuidApi][ExperimentalUuidApi]`::class)`. * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments. + * @param parseExperimentalInstant whether to allow parsing to the experimental [kotlin.time.Instant] type. + * By default, this is false and instants are recognized as the deprecated [kotlinx.datetime.Instant] type (#1350). + * NOTE: Interacting with an [Instant][kotlin.time.Instant] in your code might require + * `@`[OptIn][OptIn]`(`[ExperimentalTime][kotlin.time.ExperimentalTime]`::class)`. + * In notebooks, add `-opt-in=kotlin.time.ExperimentalTime` to the compiler arguments. */ public class ParserOptions( public val locale: Locale? = null, @@ -128,6 +143,7 @@ public class ParserOptions( public val skipTypes: Set? = null, public val useFastDoubleParser: Boolean? = null, public val parseExperimentalUuid: Boolean? = null, + public val parseExperimentalInstant: Boolean? = null, ) { /** For binary compatibility. */ @@ -150,6 +166,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) /** For binary compatibility. */ @@ -170,6 +187,7 @@ public class ParserOptions( skipTypes = null, useFastDoubleParser = null, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) /** For binary compatibility. */ @@ -193,6 +211,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) /** For binary compatibility. */ @@ -214,6 +233,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) internal fun getDateTimeFormatter(): DateTimeFormatter? = @@ -232,6 +252,7 @@ public class ParserOptions( skipTypes: Set? = this.skipTypes, useFastDoubleParser: Boolean? = this.useFastDoubleParser, parseExperimentalUuid: Boolean? = this.parseExperimentalUuid, + parseExperimentalInstant: Boolean? = this.parseExperimentalInstant, ): ParserOptions = ParserOptions( locale = locale, @@ -241,6 +262,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = parseExperimentalUuid, + parseExperimentalInstant = parseExperimentalInstant, ) override fun equals(other: Any?): Boolean { @@ -256,6 +278,7 @@ public class ParserOptions( if (nullStrings != other.nullStrings) return false if (skipTypes != other.skipTypes) return false if (parseExperimentalUuid != other.parseExperimentalUuid) return false + if (parseExperimentalInstant != other.parseExperimentalInstant) return false return true } @@ -268,11 +291,12 @@ public class ParserOptions( result = 31 * result + (nullStrings?.hashCode() ?: 0) result = 31 * result + (skipTypes?.hashCode() ?: 0) result = 31 * result + (parseExperimentalUuid?.hashCode() ?: 0) + result = 31 * result + (parseExperimentalInstant?.hashCode() ?: 0) return result } override fun toString(): String = - "ParserOptions(locale=$locale, dateTimeFormatter=$dateTimeFormatter, dateTimePattern=$dateTimePattern, nullStrings=$nullStrings, skipTypes=$skipTypes, useFastDoubleParser=$useFastDoubleParser, parseExperimentalUuid=$parseExperimentalUuid)" + "ParserOptions(locale=$locale, dateTimeFormatter=$dateTimeFormatter, dateTimePattern=$dateTimePattern, nullStrings=$nullStrings, skipTypes=$skipTypes, useFastDoubleParser=$useFastDoubleParser, parseExperimentalUuid=$parseExperimentalUuid, parseExperimentalInstant=$parseExperimentalInstant)" } /** Tries to parse a column of strings into a column of a different type. diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt index 6a72bba2f0..943cfc264d 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt @@ -1,22 +1,21 @@ package org.jetbrains.kotlinx.dataframe.impl.api -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.datetime.TimeZone import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.atTime +import kotlinx.datetime.toDeprecatedInstant import kotlinx.datetime.toInstant -import kotlinx.datetime.toJavaInstant import kotlinx.datetime.toJavaLocalDate import kotlinx.datetime.toJavaLocalDateTime import kotlinx.datetime.toJavaLocalTime -import kotlinx.datetime.toKotlinInstant import kotlinx.datetime.toKotlinLocalDate import kotlinx.datetime.toKotlinLocalDateTime import kotlinx.datetime.toKotlinLocalTime import kotlinx.datetime.toLocalDateTime +import kotlinx.datetime.toStdlibInstant import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -29,7 +28,6 @@ import org.jetbrains.kotlinx.dataframe.api.ParserOptions import org.jetbrains.kotlinx.dataframe.api.asColumn import org.jetbrains.kotlinx.dataframe.api.mapIndexed import org.jetbrains.kotlinx.dataframe.api.name -import org.jetbrains.kotlinx.dataframe.api.to import org.jetbrains.kotlinx.dataframe.columns.values import org.jetbrains.kotlinx.dataframe.dataTypes.IFRAME import org.jetbrains.kotlinx.dataframe.dataTypes.IMG @@ -56,14 +54,17 @@ import kotlin.reflect.full.primaryConstructor import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf -import kotlin.text.trim +import kotlin.time.toJavaInstant +import kotlin.time.toKotlinInstant import kotlin.toBigDecimal import java.time.Instant as JavaInstant import java.time.LocalDate as JavaLocalDate import java.time.LocalDateTime as JavaLocalDateTime import java.time.LocalTime as JavaLocalTime +import kotlin.time.Instant as StdlibInstant import kotlin.toBigDecimal as toBigDecimalKotlin import kotlin.toBigInteger as toBigIntegerKotlin +import kotlinx.datetime.Instant as DeprecatedInstant @PublishedApi internal fun Convert.withRowCellImpl( @@ -396,7 +397,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLong().toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it.toLong()) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it.toLong()) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it.toLong()) } JavaLocalDateTime::class -> convert { it.toLong().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -434,7 +438,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLong().toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it.toLong()) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it.toLong()) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it.toLong()) } JavaLocalDateTime::class -> convert { it.toLong().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -472,7 +479,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLong().toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it.toLong()) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it.toLong()) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it.toLong()) } JavaLocalDateTime::class -> convert { it.toLong().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -522,7 +532,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it) } JavaLocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -537,24 +550,58 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n else -> null } - Instant::class -> when (toClass) { - Long::class -> convert { it.toEpochMilliseconds() } + StdlibInstant::class -> when (toClass) { + Long::class -> convert { it.toEpochMilliseconds() } - LocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone) } + LocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone) } - LocalDate::class -> convert { it.toLocalDate(defaultTimeZone) } + LocalDate::class -> convert { it.toLocalDate(defaultTimeZone) } - LocalTime::class -> convert { it.toLocalTime(defaultTimeZone) } + LocalTime::class -> convert { it.toLocalTime(defaultTimeZone) } - JavaLocalDateTime::class -> convert { + JavaLocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() } - JavaLocalDate::class -> convert { it.toLocalDate(defaultTimeZone).toJavaLocalDate() } + JavaLocalDate::class -> convert { it.toLocalDate(defaultTimeZone).toJavaLocalDate() } + + JavaInstant::class -> convert { it.toJavaInstant() } - JavaInstant::class -> convert { it.toJavaInstant() } + JavaLocalTime::class -> convert { it.toLocalTime(defaultTimeZone).toJavaLocalTime() } - JavaLocalTime::class -> convert { it.toLocalTime(defaultTimeZone).toJavaLocalTime() } + // #1350 + DeprecatedInstant::class -> convert { it.toDeprecatedInstant() } + + else -> null + } + + // #1350 + DeprecatedInstant::class -> when (toClass) { + Long::class -> convert { it.toStdlibInstant().toEpochMilliseconds() } + + LocalDateTime::class -> convert { + it.toStdlibInstant().toLocalDateTime(defaultTimeZone) + } + + LocalDate::class -> convert { it.toStdlibInstant().toLocalDate(defaultTimeZone) } + + LocalTime::class -> convert { it.toStdlibInstant().toLocalTime(defaultTimeZone) } + + JavaLocalDateTime::class -> convert { + it.toStdlibInstant().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() + } + + JavaLocalDate::class -> convert { + it.toStdlibInstant().toLocalDate(defaultTimeZone).toJavaLocalDate() + } + + JavaInstant::class -> convert { it.toStdlibInstant().toJavaInstant() } + + JavaLocalTime::class -> convert { + it.toStdlibInstant().toLocalTime(defaultTimeZone).toJavaLocalTime() + } + + StdlibInstant::class -> convert { it.toStdlibInstant() } else -> null } @@ -570,7 +617,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toKotlinInstant().toLocalTime(defaultTimeZone) } - Instant::class -> convert { it.toKotlinInstant() } + StdlibInstant::class -> convert { it.toKotlinInstant() } JavaLocalDateTime::class -> convert { it.toKotlinInstant().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -584,6 +631,11 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n it.toKotlinInstant().toLocalTime(defaultTimeZone).toJavaLocalTime() } + // #1350 + DeprecatedInstant::class -> convert { + it.toKotlinInstant().toDeprecatedInstant() + } + else -> null } @@ -625,13 +677,26 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDateTime::class -> when (toClass) { LocalDate::class -> convert { it.date } + LocalTime::class -> convert { it.time } - Instant::class -> convert { it.toInstant(defaultTimeZone) } + + StdlibInstant::class -> convert { it.toInstant(defaultTimeZone) } + + // #1350 + DeprecatedInstant::class -> convert { + it.toInstant(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.toInstant(defaultTimeZone).toEpochMilliseconds() } + JavaLocalDateTime::class -> convert { it.toJavaLocalDateTime() } + JavaLocalDate::class -> convert { it.date.toJavaLocalDate() } + JavaLocalTime::class -> convert { it.toJavaLocalDateTime().toLocalTime() } + JavaInstant::class -> convert { it.toInstant(defaultTimeZone).toJavaInstant() } + else -> null } @@ -642,10 +707,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDateTime::class -> convert { it.toKotlinLocalDateTime() } - Instant::class -> convert { + StdlibInstant::class -> convert { it.toKotlinLocalDateTime().toInstant(defaultTimeZone) } + // #1350 + DeprecatedInstant::class -> convert { + it.toKotlinLocalDateTime().toInstant(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.toKotlinLocalDateTime().toInstant(defaultTimeZone).toEpochMilliseconds() } @@ -663,11 +733,22 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDate::class -> when (toClass) { LocalDateTime::class -> convert { it.atTime(0, 0) } - Instant::class -> convert { it.atStartOfDayIn(defaultTimeZone) } + + StdlibInstant::class -> convert { it.atStartOfDayIn(defaultTimeZone) } + + // #1350 + DeprecatedInstant::class -> convert { + it.atStartOfDayIn(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.atStartOfDayIn(defaultTimeZone).toEpochMilliseconds() } + JavaLocalDate::class -> convert { it.toJavaLocalDate() } + JavaLocalDateTime::class -> convert { it.atTime(0, 0).toJavaLocalDateTime() } + JavaInstant::class -> convert { it.atStartOfDayIn(defaultTimeZone).toJavaInstant() } + else -> null } @@ -676,10 +757,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDateTime::class -> convert { it.atTime(0, 0).toKotlinLocalDateTime() } - Instant::class -> convert { + StdlibInstant::class -> convert { it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone) } + // #1350 + DeprecatedInstant::class -> convert { + it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone).toEpochMilliseconds() } @@ -715,15 +801,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n } internal fun Long.toLocalDateTime(zone: TimeZone = defaultTimeZone) = - Instant.fromEpochMilliseconds(this).toLocalDateTime(zone) + StdlibInstant.fromEpochMilliseconds(this).toLocalDateTime(zone) internal fun Long.toLocalDate(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).date internal fun Long.toLocalTime(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).time -internal fun Instant.toLocalDate(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).date +internal fun StdlibInstant.toLocalDate(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).date -internal fun Instant.toLocalTime(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).time +internal fun StdlibInstant.toLocalTime(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).time internal val defaultTimeZone get() = TimeZone.currentSystemDefault() diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt index 827df998fd..d7f254fa99 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt @@ -1,12 +1,11 @@ package org.jetbrains.kotlinx.dataframe.impl.api import io.github.oshai.kotlinlogging.KotlinLogging -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.datetime.format.DateTimeComponents -import kotlinx.datetime.toKotlinInstant +import kotlinx.datetime.toDeprecatedInstant import kotlinx.datetime.toKotlinLocalDate import kotlinx.datetime.toKotlinLocalDateTime import kotlinx.datetime.toKotlinLocalTime @@ -56,6 +55,7 @@ import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf import kotlin.time.Duration +import kotlin.time.toKotlinInstant import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid import java.time.Duration as JavaDuration @@ -63,6 +63,8 @@ import java.time.Instant as JavaInstant import java.time.LocalDate as JavaLocalDate import java.time.LocalDateTime as JavaLocalDateTime import java.time.LocalTime as JavaLocalTime +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant private val logger = KotlinLogging.logger { } @@ -142,7 +144,9 @@ internal object Parsers : GlobalParserOptions { override val skipTypes: Set get() = skipTypesSet - override var parseExperimentalUuid: Boolean = false + override var parseExperimentalUuid by Delegates.notNull() + + override var parseExperimentalInstant by Delegates.notNull() override fun addDateTimePattern(pattern: String) { formatters.add(DateTimeFormatter.ofPattern(pattern)) @@ -183,6 +187,7 @@ internal object Parsers : GlobalParserOptions { useFastDoubleParser = true parseExperimentalUuid = false + parseExperimentalInstant = false _locale = null nullStrings.addAll(listOf("null", "NULL", "NA", "N/A")) } @@ -211,7 +216,7 @@ internal object Parsers : GlobalParserOptions { } } - private fun String.toInstantOrNull(): Instant? = + private fun String.toInstantOrNull(): StdlibInstant? = // low chance throwing exception, thanks to using parseOrNull instead of parse catchSilent { // Default format used by Instant.parse @@ -439,12 +444,24 @@ internal object Parsers : GlobalParserOptions { stringParser { it.toIntOrNull() }, // Long stringParser { it.toLongOrNull() }, + // kotlin.time.Instant + stringParserWithOptions { + val parseExperimentalInstant = it?.parseExperimentalInstant ?: this.parseExperimentalInstant + val parser = { it: String -> + if (parseExperimentalInstant) { + it.toInstantOrNull() + } else { + null + } + } + parser + }, // kotlinx.datetime.Instant - stringParser { - it.toInstantOrNull() + stringParser { + it.toInstantOrNull()?.toDeprecatedInstant() }, // java.time.Instant, will be skipped if kotlinx.datetime.Instant is already checked - stringParser(coveredBy = setOf(typeOf())) { + stringParser(coveredBy = setOf(typeOf())) { it.toJavaInstantOrNull() }, // kotlinx.datetime.LocalDateTime diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt index 9d213b2c0f..948525a9ad 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt @@ -37,6 +37,8 @@ import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField import kotlin.reflect.typeOf +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant // non-standard value types (not supertypes, but exact types) private val valueTypes = setOf( @@ -52,7 +54,8 @@ private val valueTypes = setOf( kotlin.time.Duration::class, kotlinx.datetime.LocalDate::class, kotlinx.datetime.LocalDateTime::class, - kotlinx.datetime.Instant::class, + DeprecatedInstant::class, + StdlibInstant::class, kotlinx.datetime.TimeZone::class, kotlinx.datetime.DateTimePeriod::class, kotlinx.datetime.DateTimeUnit::class, diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt index fc370459af..3604b8b911 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt @@ -1,6 +1,5 @@ package org.jetbrains.kotlinx.dataframe.io -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -20,6 +19,10 @@ import org.jetbrains.kotlinx.dataframe.util.APACHE_CSV import org.jetbrains.kotlinx.dataframe.util.AS_URL import org.jetbrains.kotlinx.dataframe.util.AS_URL_IMPORT import org.jetbrains.kotlinx.dataframe.util.AS_URL_REPLACE +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_DEPRECATED_INSTANT +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_DEPRECATED_INSTANT_REPLACE +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_INSTANT +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_INSTANT_REPLACE import org.jetbrains.kotlinx.dataframe.util.DF_READ_NO_CSV import org.jetbrains.kotlinx.dataframe.util.DF_READ_NO_CSV_REPLACE import org.jetbrains.kotlinx.dataframe.util.READ_CSV @@ -59,6 +62,8 @@ import kotlin.reflect.KClass import kotlin.reflect.KType import kotlin.reflect.typeOf import kotlin.time.Duration +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant @Deprecated(message = APACHE_CSV, level = DeprecationLevel.WARNING) public class CSV(private val delimiter: Char = ',') : SupportedDataFrameFormat { @@ -329,12 +334,28 @@ public enum class ColType { LocalTime, LocalDateTime, String, + + @Deprecated( + message = COL_TYPE_INSTANT, + replaceWith = ReplaceWith(COL_TYPE_INSTANT_REPLACE), + level = DeprecationLevel.ERROR, + ) Instant, Duration, Url, JsonArray, JsonObject, Char, + + @Deprecated( + message = COL_TYPE_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(COL_TYPE_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, + ) + DeprecatedInstant, + + /** Temporary, will be renamed to [Instant] in 1.1+ */ + StdlibInstant, ; public companion object { @@ -352,21 +373,44 @@ public fun ColType.toType(): KClass<*> = toKType().classifier as KClass<*> public fun ColType.toKType(): KType = when (this) { ColType.Int -> typeOf() + ColType.Long -> typeOf() + ColType.Double -> typeOf() + ColType.Boolean -> typeOf() + ColType.BigDecimal -> typeOf() + ColType.BigInteger -> typeOf() + ColType.LocalDate -> typeOf() + ColType.LocalTime -> typeOf() + ColType.LocalDateTime -> typeOf() + ColType.String -> typeOf() - ColType.Instant -> typeOf() + + ColType.DeprecatedInstant -> typeOf() + + ColType.StdlibInstant -> typeOf() + ColType.Duration -> typeOf() + ColType.Url -> typeOf() + ColType.JsonArray -> typeOf>() + ColType.JsonObject -> typeOf>() + ColType.Char -> typeOf() + + else -> { + // can't reference ColType.Instant directly because of the deprecation cycle + require(this.name == "Instant") { "Unknown column type: $this" } + typeOf() + } } @Deprecated( diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt index e65f29c732..7f10091200 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt @@ -125,6 +125,18 @@ internal const val COLS_TO_ALL_REPLACE = "this.all()" internal const val COLS_TO_ALL_COLS = "This `cols()` overload will be removed in favor of `allCols()`. $MESSAGE_1_0" internal const val COLS_TO_ALL_COLS_REPLACE = "this.allCols()" +internal const val CONVERT_TO_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Either migrate to kotlin.time.Instant and use convertToStdlibInstant() or use convertToDeprecatedInstant(). $MESSAGE_1_0 and migrated to kotlin.time.Instant in 1.1." +internal const val CONVERT_TO_INSTANT_REPLACE = "this.convertToDeprecatedInstant()" + +internal const val TO_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Either migrate to kotlin.time.Instant and use toStdlibInstant() or use toDeprecatedInstant(). $MESSAGE_1_0 and migrated to kotlin.time.Instant in 1.1." +internal const val TO_INSTANT_REPLACE = "this.toDeprecatedInstant()" + +internal const val COL_TYPE_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Either migrate to kotlin.time.Instant and use ColType.StdlibInstant or use ColType.DeprecatedInstant. $MESSAGE_1_0 and migrated to kotlin.time.Instant in 1.1." +internal const val COL_TYPE_INSTANT_REPLACE = "ColType.DeprecatedInstant" + // endregion // region WARNING in 1.0, ERROR in 1.1 @@ -202,6 +214,19 @@ internal const val GENERATE_CODE_REPLACE2 = internal const val GENERATE_INTERFACES = "This function is just here for binary compatibility. $MESSAGE_1_1" internal const val UNIFIED_SIMILAR_CS_API = "Deprecated duplicated functionality. $MESSAGE_1_1" + +internal const val CONVERT_TO_DEPRECATED_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Migrate to kotlin.time.Instant and use convertToStdlibInstant() at your own pace. $MESSAGE_1_1" +internal const val CONVERT_TO_DEPRECATED_INSTANT_REPLACE = "this.convertToStdlibInstant()" + +internal const val TO_DEPRECATED_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Migrate to kotlin.time.Instant and use toStdlibInstant() at your own pace. $MESSAGE_1_1" +internal const val TO_DEPRECATED_INSTANT_REPLACE = "this.toStdlibInstant()" + +internal const val COL_TYPE_DEPRECATED_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Migrate to kotlin.time.Instant and use Coltype.StdlibInstant at your own pace. $MESSAGE_1_1" +internal const val COL_TYPE_DEPRECATED_INSTANT_REPLACE = "ColType.StdlibInstant" + // endregion // region keep across releases diff --git a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt index 0350b8ab71..b3f6f98d9d 100644 --- a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt +++ b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt @@ -4,15 +4,14 @@ import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import kotlinx.datetime.DateTimeUnit -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.datetime.Month import kotlinx.datetime.format.DateTimeComponents import kotlinx.datetime.plus -import kotlinx.datetime.toJavaInstant -import kotlinx.datetime.toKotlinInstant +import kotlinx.datetime.toDeprecatedInstant +import kotlinx.datetime.toStdlibInstant import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.api.Parsers import org.jetbrains.kotlinx.dataframe.impl.catchSilent @@ -29,10 +28,14 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.nanoseconds import kotlin.time.Duration.Companion.seconds +import kotlin.time.toJavaInstant +import kotlin.time.toKotlinInstant import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid import java.time.Duration as JavaDuration import java.time.Instant as JavaInstant +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant class ParseTests { @Test @@ -48,14 +51,14 @@ class ParseTests { parsed.type() shouldBe typeOf() with(parsed[0]) { month shouldBe Month.JANUARY - dayOfMonth shouldBe 1 + day shouldBe 1 year shouldBe 2020 } date.convertToLocalDate(pattern) shouldBe parsed with(date.toDataFrame()) { - convert { date }.toLocalDate(pattern)[date] shouldBe parsed - parse(ParserOptions(dateTimePattern = pattern))[date] shouldBe parsed + convert { date }.toLocalDate(pattern)[date.name] shouldBe parsed + parse(ParserOptions(dateTimePattern = pattern))[date.name] shouldBe parsed } DataFrame.parser.addDateTimePattern(pattern) @@ -154,19 +157,25 @@ class ParseTests { @Test fun `parse instant`() { - columnOf("2022-01-23T04:29:40Z").parse().type shouldBe typeOf() - columnOf("2022-01-23T04:29:40+01:00").parse().type shouldBe typeOf() + columnOf("2022-01-23T04:29:40Z").parse().type shouldBe typeOf() + columnOf("2022-01-23T04:29:40+01:00").parse().type shouldBe typeOf() + + val options = ParserOptions(parseExperimentalInstant = true) + columnOf("2022-01-23T04:29:40Z").parse(options).type shouldBe typeOf() + columnOf("2022-01-23T04:29:40+01:00").parse(options).type shouldBe typeOf() columnOf("2022-01-23T04:29:40").parse().type shouldBe typeOf() } @Test fun `can parse instants`() { - val instantParser = Parsers[typeOf()]!!.applyOptions(null) + val deprecatedInstantParser = Parsers[typeOf()]!!.applyOptions(null) + val stdlibInstantParser = Parsers[typeOf()]!! + .applyOptions(ParserOptions(parseExperimentalInstant = true)) val javaInstantParser = Parsers[typeOf()]!!.applyOptions(null) // from the kotlinx-datetime tests, java instants treat leap seconds etc. like this - fun parseInstantLikeJavaDoesOrNull(input: String): Instant? = + fun parseInstantLikeJavaDoesOrNull(input: String): StdlibInstant? = catchSilent { DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET.parseOrNull(input)?.apply { when { @@ -187,21 +196,35 @@ class ParseTests { for (second in listOf(0..5, 58..62).flatten()) { val input = "2020-03-16T$hour:${formatTwoDigits(minute)}:${formatTwoDigits(second)}Z" - val myParserRes = instantParser(input) as Instant? - val myJavaParserRes = javaInstantParser(input) as JavaInstant? - val instantRes = catchSilent { Instant.parse(input) } - val instantLikeJava = parseInstantLikeJavaDoesOrNull(input) - val javaInstantRes = catchSilent { JavaInstant.parse(input) } + val deprecatedParserRes = deprecatedInstantParser(input) as DeprecatedInstant? + val javaParserRes = javaInstantParser(input) as JavaInstant? + val stdlibParserRes = stdlibInstantParser(input) as StdlibInstant? - // our parser has a fallback mechanism built in, like this - myParserRes shouldBe (instantRes ?: javaInstantRes?.toKotlinInstant()) - myParserRes shouldBe instantLikeJava + val deprecatedInstantRes = catchSilent { DeprecatedInstant.parse(input) } + val stdlibInstantRes = catchSilent { StdlibInstant.parse(input) } - myJavaParserRes shouldBe javaInstantRes + val stdlibInstantLikeJava = parseInstantLikeJavaDoesOrNull(input) + val javaInstantRes = catchSilent { JavaInstant.parse(input) } + + javaParserRes?.toKotlinInstant() shouldBe stdlibParserRes - myParserRes?.toJavaInstant() shouldBe instantLikeJava?.toJavaInstant() - instantLikeJava?.toJavaInstant() shouldBe myJavaParserRes - myJavaParserRes shouldBe javaInstantRes + // our parser has a fallback mechanism built in, like this + deprecatedParserRes shouldBe ( + deprecatedInstantRes ?: javaInstantRes?.toKotlinInstant()?.toDeprecatedInstant() + ) + deprecatedParserRes shouldBe stdlibInstantLikeJava?.toDeprecatedInstant() + + stdlibParserRes shouldBe (stdlibInstantRes ?: javaInstantRes?.toKotlinInstant()) + stdlibParserRes shouldBe stdlibInstantLikeJava + + javaParserRes shouldBe javaInstantRes + + deprecatedParserRes?.toStdlibInstant()?.toJavaInstant() shouldBe ( + stdlibInstantLikeJava?.toJavaInstant() + ) + stdlibParserRes?.toJavaInstant() shouldBe stdlibInstantLikeJava?.toJavaInstant() + stdlibInstantLikeJava?.toJavaInstant() shouldBe javaParserRes + javaParserRes shouldBe javaInstantRes } } } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt index 9569b9a196..30aae163c3 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt @@ -1,11 +1,11 @@ package org.jetbrains.kotlinx.dataframe.api -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime +import kotlinx.datetime.toStdlibInstant import org.jetbrains.kotlinx.dataframe.AnyBaseCol import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.AnyFrame @@ -22,6 +22,7 @@ import org.jetbrains.kotlinx.dataframe.annotations.Converter import org.jetbrains.kotlinx.dataframe.annotations.HasSchema import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine +import org.jetbrains.kotlinx.dataframe.api.convertToDeprecatedInstant import org.jetbrains.kotlinx.dataframe.columns.BaseColumn import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -49,10 +50,18 @@ import org.jetbrains.kotlinx.dataframe.impl.headPlusArray import org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser import org.jetbrains.kotlinx.dataframe.io.toDataFrame import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_DEPRECATED_INSTANT +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_DEPRECATED_INSTANT_REPLACE +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_INSTANT +import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_INSTANT_REPLACE import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_REPLACE import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_URL import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_URL_REPLACE import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API +import org.jetbrains.kotlinx.dataframe.util.TO_DEPRECATED_INSTANT +import org.jetbrains.kotlinx.dataframe.util.TO_DEPRECATED_INSTANT_REPLACE +import org.jetbrains.kotlinx.dataframe.util.TO_INSTANT +import org.jetbrains.kotlinx.dataframe.util.TO_INSTANT_REPLACE import org.jetbrains.kotlinx.dataframe.util.TO_URL import org.jetbrains.kotlinx.dataframe.util.TO_URL_REPLACE import java.math.BigDecimal @@ -64,6 +73,8 @@ import kotlin.reflect.KProperty import kotlin.reflect.KType import kotlin.reflect.full.isSubtypeOf import kotlin.reflect.typeOf +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant /** * See also [parse] — a specialized form of the [convert] operation that parses [String] columns @@ -118,7 +129,8 @@ internal interface ConvertDocs { * * [Byte], [Short], [Char]; * * [Int], [Long], [Float], [Double]; * * [BigDecimal], [BigInteger]; - * * [LocalDateTime], [LocalDate], [LocalTime], [Instant] ( (kotlinx.datetime and [java.time]), + * * [LocalDateTime], [LocalDate], [LocalTime], + * `Instant` ([kotlinx.datetime][DeprecatedInstant], [kotlin.time][StdlibInstant], and [java.time]), * * [URL], [IMG], [IFRAME]. */ interface SupportedTypes @@ -322,7 +334,8 @@ public inline fun Convert.notNull( * - [asFrame][Convert.asFrame] – converts [column groups][ColumnGroup] as a [DataFrame] with the given expression. * - [toStr], [toInt], [toLong], [toDouble], [toFloat], [toBigDecimal], * [toBigInteger], [toBoolean] – convert to standard types. - * - [toLocalDateTime], [toLocalDate], [toLocalTime], [toInstant] – convert to kotlinx.datetime types. + * - [toLocalDateTime], [toLocalDate], [toLocalTime] – convert to kotlinx.datetime types. + * - [toInstant] (temporarily deprecated), [toStdlibInstant], [toDeprecatedInstant] – convert to `Instant` * - [toUrl], [toIFrame], [toImg] – convert to special types. * - [toDataFrames] – converts a column of lists into separate DataFrames. * @@ -1036,22 +1049,135 @@ public fun Convert.toUrl(): DataFrame = asColumn { it.convertT // region toInstant /** - * Converts values in this [String] column to [Instant]. + * __Deprecated__: * - * @return A new [DataColumn] with the [Instant] values. + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] or use [convertToDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. */ -public fun DataColumn.convertToInstant(): DataColumn = map { Instant.parse(it) } +@Deprecated( + message = CONVERT_TO_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_INSTANT_REPLACE), + level = DeprecationLevel.ERROR, +) +public fun DataColumn.convertToInstant(): DataColumn = map { DeprecatedInstant.parse(it) } /** - * Converts values in this [String] column to [Instant]. Preserves null values. + * __Deprecated__: * - * @return A new [DataColumn] with the [Instant] nullable values. + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] or use [convertToDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. */ @JvmName("convertToInstantFromStringNullable") -public fun DataColumn.convertToInstant(): DataColumn = map { it?.let { Instant.parse(it) } } +@Deprecated( + message = CONVERT_TO_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_INSTANT_REPLACE), + level = DeprecationLevel.ERROR, +) +public fun DataColumn.convertToInstant(): DataColumn = + map { it?.let { DeprecatedInstant.parse(it) } } /** - * Converts values in the [String] columns previously selected with [convert] to the [Instant], + * Converts values in this [String] column to the deprecated [kotlinx.datetime.Instant]. + * + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataColumn] with the [kotlinx.datetime.Instant] values. + */ +@Deprecated( + message = CONVERT_TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +public fun DataColumn.convertToDeprecatedInstant(): DataColumn = + map { DeprecatedInstant.parse(it) } + +/** + * Converts values in this [String] column to the deprecated [kotlinx.datetime.Instant]. Preserves null values. + * + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataColumn] with the nullable [kotlinx.datetime.Instant] values. + */ +@Deprecated( + message = CONVERT_TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(CONVERT_TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +@JvmName("convertToDeprecatedInstantFromStringNullable") +public fun DataColumn.convertToDeprecatedInstant(): DataColumn = + map { it?.let { DeprecatedInstant.parse(it) } } + +/** + * Converts values in this [String] column to [kotlin.time.Instant]. + * + * This function will be renamed to `.convertToInstant()` in 1.1. + * + * @return A new [DataColumn] with the [kotlin.time.Instant] values. + */ +public fun DataColumn.convertToStdlibInstant(): DataColumn = map { StdlibInstant.parse(it) } + +/** + * Converts values in this [String] column to [kotlin.time.Instant]. Preserves null values. + * + * This function will be renamed to `.convertToInstant()` in 1.1. + * + * @return A new [DataColumn] with the [kotlin.time.Instant] nullable values. + */ +@JvmName("convertToStdlibInstantFromStringNullable") +public fun DataColumn.convertToStdlibInstant(): DataColumn = + map { it?.let { StdlibInstant.parse(it) } } + +/** + * Converts values in this [kotlinx.datetime.Instant] column to [kotlin.time.Instant]. + * + * @return A new [DataColumn] with the [kotlin.time.Instant] values. + */ +@JvmName("convertToStdlibInstantFromDeprecatedInstant") +public fun DataColumn.convertToStdlibInstant(): DataColumn = + map { it.toStdlibInstant() } + +/** + * Converts values in this [kotlinx.datetime.Instant] column to [kotlin.time.Instant]. Preserves null values. + * + * @return A new [DataColumn] with the [kotlin.time.Instant] nullable values. + */ +@JvmName("convertToStdlibInstantFromDeprecatedInstantNullable") +public fun DataColumn.convertToStdlibInstant(): DataColumn = + map { it?.toStdlibInstant() } + +/** + * __Deprecated__: + * + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [toStdlibInstant] or use [toDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. + */ + +@JvmName("toInstantFromStringNullable") +@Refine +@Converter(DeprecatedInstant::class, nullable = true) +@Interpretable("ToSpecificType") +@Deprecated(message = TO_INSTANT, replaceWith = ReplaceWith(TO_INSTANT_REPLACE), level = DeprecationLevel.ERROR) +public fun Convert.toInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } + +/** + * __Deprecated__: + * + * [kotlinx.datetime.Instant] is deprecated in favor of [kotlin.time.Instant]. + * Either migrate to [kotlin.time.Instant] and use [toStdlibInstant] or use [toDeprecatedInstant]. + * This function will be migrated to [kotlin.time.Instant] in 1.1. + */ +@JvmName("toInstantFromString") +@Refine +@Converter(DeprecatedInstant::class, nullable = false) +@Interpretable("ToSpecificType") +@Deprecated(message = TO_INSTANT, replaceWith = ReplaceWith(TO_INSTANT_REPLACE), level = DeprecationLevel.ERROR) +public fun Convert.toInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } + +/** + * Converts values in the [String] columns previously selected with [convert] to [kotlinx.datetime.Instant], * preserving their original names and positions within the [DataFrame]. * Preserves null values. * @@ -1059,36 +1185,131 @@ public fun DataColumn.convertToInstant(): DataColumn = map { * * ### Examples: * ```kotlin - * df.convert { timestamp }.toInstant() + * df.convert { timestamp }.toDeprecatedInstant() * ``` * - * @return A new [DataFrame] with the values converted to [Instant]. + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataFrame] with the values converted to [kotlinx.datetime.Instant]. */ -@JvmName("toInstantFromStringNullable") +@JvmName("toDeprecatedInstantFromStringNullable") @Refine -@Converter(Instant::class, nullable = true) +@Converter(DeprecatedInstant::class, nullable = true) @Interpretable("ToSpecificType") -public fun Convert.toInstant(): DataFrame = asColumn { it.convertToInstant() } +@Deprecated( + message = TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +public fun Convert.toDeprecatedInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } /** - * Converts values in the [String] columns previously selected with [convert] to the [Instant], + * Converts values in the [String] columns previously selected with [convert] to [kotlinx.datetime.Instant], * preserving their original names and positions within the [DataFrame]. * * For more information: {@include [DocumentationUrls.Convert]} * * ### Examples: * ```kotlin - * df.convert { timestamp }.toInstant() + * df.convert { timestamp }.toDeprecatedInstant() * ``` * - * @return A new [DataFrame] with the values converted to [Instant]. + * Migrate to [kotlin.time.Instant] and use [convertToStdlibInstant] at your own pace. + * + * @return A new [DataFrame] with the values converted to [kotlinx.datetime.Instant]. */ -@JvmName("toInstantFromString") +@JvmName("toDeprecatedInstantFromString") +@Refine +@Converter(DeprecatedInstant::class, nullable = false) +@Interpretable("ToSpecificType") +@Deprecated( + message = TO_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(TO_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, +) +public fun Convert.toDeprecatedInstant(): DataFrame = asColumn { it.convertToDeprecatedInstant() } + +/** + * Converts values in the [String] columns previously selected with [convert] to [kotlin.time.Instant], + * preserving their original names and positions within the [DataFrame]. + * Preserves null values. + * + * For more information: {@include [DocumentationUrls.Convert]} + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toStdlibInstant() + * ``` + * + * This function will be renamed to `.toInstant()` in 1.1. + * + * @return A new [DataFrame] with the values converted to [kotlin.time.Instant]. + */ +@JvmName("toStdlibInstantFromStringNullable") +@Refine +@Converter(StdlibInstant::class, nullable = true) +@Interpretable("ToSpecificType") +public fun Convert.toStdlibInstant(): DataFrame = asColumn { it.convertToStdlibInstant() } + +/** + * Converts values in the [String] columns previously selected with [convert] to [kotlin.time.Instant], + * preserving their original names and positions within the [DataFrame]. + * + * For more information: {@include [DocumentationUrls.Convert]} + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toStdlibInstant() + * ``` + * + * This function will be renamed to `.toInstant()` in 1.1. + * + * @return A new [DataFrame] with the values converted to [kotlin.time.Instant]. + */ +@JvmName("toStdlibInstantFromString") @Refine -@Converter(Instant::class, nullable = false) +@Converter(StdlibInstant::class, nullable = false) @Interpretable("ToSpecificType") -public fun Convert.toInstant(): DataFrame = asColumn { it.convertToInstant() } +public fun Convert.toStdlibInstant(): DataFrame = asColumn { it.convertToStdlibInstant() } +/** + * Converts values in the [kotlinx.datetime.Instant] columns previously selected with [convert] to [kotlin.time.Instant], + * preserving their original names and positions within the [DataFrame]. + * Preserves null values. + * + * For more information: {@include [DocumentationUrls.Convert]} + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toStdlibInstant() + * ``` + * + * @return A new [DataFrame] with the values converted to [kotlin.time.Instant]. + */ +@JvmName("toStdlibInstantFromDeprecatedInstantNullable") +@Refine +@Converter(StdlibInstant::class, nullable = true) +@Interpretable("ToSpecificType") +public fun Convert.toStdlibInstant(): DataFrame = asColumn { it.convertToStdlibInstant() } + +/** + * Converts values in the [kotlinx.datetime.Instant] columns previously selected with [convert] to the [kotlin.time.Instant], + * preserving their original names and positions within the [DataFrame]. + * + * For more information: {@include [DocumentationUrls.Convert]} + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toStdlibInstant() + * ``` + * + * @return A new [DataFrame] with the values converted to [kotlin.time.Instant]. + */ +@JvmName("toStdlibInstantFromDeprecatedInstant") +@Refine +@Converter(StdlibInstant::class, nullable = false) +@Interpretable("ToSpecificType") +public fun Convert.toStdlibInstant(): DataFrame = asColumn { it.convertToStdlibInstant() } // endregion // region toLocalDate @@ -1589,26 +1810,52 @@ public fun DataColumn.convertToLocalDateTime(zone: TimeZone = defaultTime map { it?.toLocalDateTime(zone) } /** - * Converts values in this [Instant] column to [LocalDateTime]. + * Converts values in this [kotlinx.datetime.Instant] column to [LocalDateTime]. * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a date-time. + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a date-time. * Defaults to the system current time zone. * @return A new [DataColumn] with the [LocalDateTime] values. */ -@JvmName("convertToLocalDateTimeFromInstant") -public fun DataColumn.convertToLocalDateTime(zone: TimeZone = defaultTimeZone): DataColumn = - map { it.toLocalDateTime(zone) } +@JvmName("convertToLocalDateTimeFromDeprecatedInstant") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it.toLocalDateTime(zone) } /** - * Converts values in this [Instant] column to [LocalDateTime]. Preserves null values. + * Converts values in this [kotlinx.datetime.Instant] column to [LocalDateTime]. Preserves null values. * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a date-time. + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a date-time. * Defaults to the system current time zone. * @return A new [DataColumn] with the [LocalDateTime] nullable values. */ -@JvmName("convertToLocalDateTimeFromInstantNullable") -public fun DataColumn.convertToLocalDateTime(zone: TimeZone = defaultTimeZone): DataColumn = - map { it?.toLocalDateTime(zone) } +@JvmName("convertToLocalDateTimeFromDeprecatedInstantNullable") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it?.toLocalDateTime(zone) } + +/** + * Converts values in this [kotlin.time.Instant] column to [LocalDateTime]. + * + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a date-time. + * Defaults to the system current time zone. + * @return A new [DataColumn] with the [LocalDateTime] values. + */ +@JvmName("convertToLocalDateTimeFromStdlibInstant") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it.toLocalDateTime(zone) } + +/** + * Converts values in this [kotlin.time.Instant] column to [LocalDateTime]. Preserves null values. + * + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a date-time. + * Defaults to the system current time zone. + * @return A new [DataColumn] with the [LocalDateTime] nullable values. + */ +@JvmName("convertToLocalDateTimeFromStdlibInstantNullable") +public fun DataColumn.convertToLocalDateTime( + zone: TimeZone = defaultTimeZone, +): DataColumn = map { it?.toLocalDateTime(zone) } /** * Converts values in this [Int] column to [LocalDateTime]. @@ -1715,7 +1962,50 @@ public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone asColumn { it.convertToLocalDateTime(zone) } /** - * Converts values in the [Instant] columns previously selected with [convert] to the [LocalDateTime], + * Converts values in the [kotlinx.datetime.Instant] columns previously selected with [convert] to the [LocalDateTime], + * preserving their original names and positions within the [DataFrame]. + * Preserves null values. + * + * For more information: {@include [DocumentationUrls.Convert]} + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toLocalDateTime() + * ``` + * + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a time. Defaults to the system current time zone. + * @return A new [DataFrame] with the values converted to [LocalDateTime]. + */ +@JvmName("toLocalDateTimeFromTDeprecatedInstantNullable") +@Refine +@Converter(LocalDateTime::class, nullable = true) +@Interpretable("ToSpecificTypeZone") +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = + asColumn { it.convertToLocalDateTime(zone) } + +/** + * Converts values in the [kotlinx.datetime.Instant] columns previously selected with [convert] to the [LocalDateTime], + * preserving their original names and positions within the [DataFrame]. + * + * For more information: {@include [DocumentationUrls.Convert]} + * + * ### Examples: + * ```kotlin + * df.convert { timestamp }.toLocalDateTime() + * ``` + * + * @param zone The [TimeZone] used to interpret the [kotlinx.datetime.Instant] timestamp as a time. Defaults to the system current time zone. + * @return A new [DataFrame] with the values converted to [LocalDateTime]. + */ +@JvmName("toLocalDateTimeFromTDeprecatedInstant") +@Refine +@Converter(LocalDateTime::class, nullable = false) +@Interpretable("ToSpecificTypeZone") +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = + asColumn { it.convertToLocalDateTime(zone) } + +/** + * Converts values in the [kotlin.time.Instant] columns previously selected with [convert] to the [LocalDateTime], * preserving their original names and positions within the [DataFrame]. * Preserves null values. * @@ -1726,18 +2016,18 @@ public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone * df.convert { timestamp }.toLocalDateTime() * ``` * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a time. Defaults to the system current time zone. + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a time. Defaults to the system current time zone. * @return A new [DataFrame] with the values converted to [LocalDateTime]. */ -@JvmName("toLocalDateTimeFromTInstantNullable") +@JvmName("toLocalDateTimeFromTStdlibInstantNullable") @Refine @Converter(LocalDateTime::class, nullable = true) @Interpretable("ToSpecificTypeZone") -public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = asColumn { it.convertToLocalDateTime(zone) } /** - * Converts values in the [Instant] columns previously selected with [convert] to the [LocalDateTime], + * Converts values in the [kotlin.time.Instant] columns previously selected with [convert] to the [LocalDateTime], * preserving their original names and positions within the [DataFrame]. * * For more information: {@include [DocumentationUrls.Convert]} @@ -1747,14 +2037,14 @@ public fun Convert.toLocalDateTime(zone: TimeZone = defaultTime * df.convert { timestamp }.toLocalDateTime() * ``` * - * @param zone The [TimeZone] used to interpret the [Instant] timestamp as a time. Defaults to the system current time zone. + * @param zone The [TimeZone] used to interpret the [kotlin.time.Instant] timestamp as a time. Defaults to the system current time zone. * @return A new [DataFrame] with the values converted to [LocalDateTime]. */ -@JvmName("toLocalDateTimeFromTInstant") +@JvmName("toLocalDateTimeFromTStdlibInstant") @Refine @Converter(LocalDateTime::class, nullable = false) @Interpretable("ToSpecificTypeZone") -public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = +public fun Convert.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame = asColumn { it.convertToLocalDateTime(zone) } /** diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt index bd00778814..ff7f4b6460 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt @@ -85,6 +85,16 @@ public interface GlobalParserOptions { * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments. */ public var parseExperimentalUuid: Boolean + + /** + * Whether to allow parsing to the experimental [kotlin.time.Instant] type. + * By default, this is false and instants are recognized as the deprecated [kotlinx.datetime.Instant] type (#1350). + * + * NOTE: Interacting with an [Instant][kotlin.time.Instant] in your code might require + * `@`[OptIn][OptIn]`(`[ExperimentalTime][kotlin.time.ExperimentalTime]`::class)`. + * In notebooks, add `-opt-in=kotlin.time.ExperimentalTime` to the compiler arguments. + */ + public var parseExperimentalInstant: Boolean } /** @@ -118,6 +128,11 @@ public interface GlobalParserOptions { * NOTE: Interacting with a [Uuid][Uuid] in your code might require * `@`[OptIn][OptIn]`(`[ExperimentalUuidApi][ExperimentalUuidApi]`::class)`. * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments. + * @param parseExperimentalInstant whether to allow parsing to the experimental [kotlin.time.Instant] type. + * By default, this is false and instants are recognized as the deprecated [kotlinx.datetime.Instant] type (#1350). + * NOTE: Interacting with an [Instant][kotlin.time.Instant] in your code might require + * `@`[OptIn][OptIn]`(`[ExperimentalTime][kotlin.time.ExperimentalTime]`::class)`. + * In notebooks, add `-opt-in=kotlin.time.ExperimentalTime` to the compiler arguments. */ public class ParserOptions( public val locale: Locale? = null, @@ -128,6 +143,7 @@ public class ParserOptions( public val skipTypes: Set? = null, public val useFastDoubleParser: Boolean? = null, public val parseExperimentalUuid: Boolean? = null, + public val parseExperimentalInstant: Boolean? = null, ) { /** For binary compatibility. */ @@ -150,6 +166,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) /** For binary compatibility. */ @@ -170,6 +187,7 @@ public class ParserOptions( skipTypes = null, useFastDoubleParser = null, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) /** For binary compatibility. */ @@ -193,6 +211,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) /** For binary compatibility. */ @@ -214,6 +233,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = null, + parseExperimentalInstant = null, ) internal fun getDateTimeFormatter(): DateTimeFormatter? = @@ -232,6 +252,7 @@ public class ParserOptions( skipTypes: Set? = this.skipTypes, useFastDoubleParser: Boolean? = this.useFastDoubleParser, parseExperimentalUuid: Boolean? = this.parseExperimentalUuid, + parseExperimentalInstant: Boolean? = this.parseExperimentalInstant, ): ParserOptions = ParserOptions( locale = locale, @@ -241,6 +262,7 @@ public class ParserOptions( skipTypes = skipTypes, useFastDoubleParser = useFastDoubleParser, parseExperimentalUuid = parseExperimentalUuid, + parseExperimentalInstant = parseExperimentalInstant, ) override fun equals(other: Any?): Boolean { @@ -256,6 +278,7 @@ public class ParserOptions( if (nullStrings != other.nullStrings) return false if (skipTypes != other.skipTypes) return false if (parseExperimentalUuid != other.parseExperimentalUuid) return false + if (parseExperimentalInstant != other.parseExperimentalInstant) return false return true } @@ -268,11 +291,12 @@ public class ParserOptions( result = 31 * result + (nullStrings?.hashCode() ?: 0) result = 31 * result + (skipTypes?.hashCode() ?: 0) result = 31 * result + (parseExperimentalUuid?.hashCode() ?: 0) + result = 31 * result + (parseExperimentalInstant?.hashCode() ?: 0) return result } override fun toString(): String = - "ParserOptions(locale=$locale, dateTimeFormatter=$dateTimeFormatter, dateTimePattern=$dateTimePattern, nullStrings=$nullStrings, skipTypes=$skipTypes, useFastDoubleParser=$useFastDoubleParser, parseExperimentalUuid=$parseExperimentalUuid)" + "ParserOptions(locale=$locale, dateTimeFormatter=$dateTimeFormatter, dateTimePattern=$dateTimePattern, nullStrings=$nullStrings, skipTypes=$skipTypes, useFastDoubleParser=$useFastDoubleParser, parseExperimentalUuid=$parseExperimentalUuid, parseExperimentalInstant=$parseExperimentalInstant)" } /** @include [tryParseImpl] */ diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt index 6a72bba2f0..943cfc264d 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/convert.kt @@ -1,22 +1,21 @@ package org.jetbrains.kotlinx.dataframe.impl.api -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.datetime.TimeZone import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.atTime +import kotlinx.datetime.toDeprecatedInstant import kotlinx.datetime.toInstant -import kotlinx.datetime.toJavaInstant import kotlinx.datetime.toJavaLocalDate import kotlinx.datetime.toJavaLocalDateTime import kotlinx.datetime.toJavaLocalTime -import kotlinx.datetime.toKotlinInstant import kotlinx.datetime.toKotlinLocalDate import kotlinx.datetime.toKotlinLocalDateTime import kotlinx.datetime.toKotlinLocalTime import kotlinx.datetime.toLocalDateTime +import kotlinx.datetime.toStdlibInstant import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -29,7 +28,6 @@ import org.jetbrains.kotlinx.dataframe.api.ParserOptions import org.jetbrains.kotlinx.dataframe.api.asColumn import org.jetbrains.kotlinx.dataframe.api.mapIndexed import org.jetbrains.kotlinx.dataframe.api.name -import org.jetbrains.kotlinx.dataframe.api.to import org.jetbrains.kotlinx.dataframe.columns.values import org.jetbrains.kotlinx.dataframe.dataTypes.IFRAME import org.jetbrains.kotlinx.dataframe.dataTypes.IMG @@ -56,14 +54,17 @@ import kotlin.reflect.full.primaryConstructor import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf -import kotlin.text.trim +import kotlin.time.toJavaInstant +import kotlin.time.toKotlinInstant import kotlin.toBigDecimal import java.time.Instant as JavaInstant import java.time.LocalDate as JavaLocalDate import java.time.LocalDateTime as JavaLocalDateTime import java.time.LocalTime as JavaLocalTime +import kotlin.time.Instant as StdlibInstant import kotlin.toBigDecimal as toBigDecimalKotlin import kotlin.toBigInteger as toBigIntegerKotlin +import kotlinx.datetime.Instant as DeprecatedInstant @PublishedApi internal fun Convert.withRowCellImpl( @@ -396,7 +397,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLong().toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it.toLong()) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it.toLong()) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it.toLong()) } JavaLocalDateTime::class -> convert { it.toLong().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -434,7 +438,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLong().toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it.toLong()) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it.toLong()) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it.toLong()) } JavaLocalDateTime::class -> convert { it.toLong().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -472,7 +479,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLong().toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it.toLong()) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it.toLong()) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it.toLong()) } JavaLocalDateTime::class -> convert { it.toLong().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -522,7 +532,10 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toLocalTime(defaultTimeZone) } - Instant::class -> convert { Instant.fromEpochMilliseconds(it) } + StdlibInstant::class -> convert { StdlibInstant.fromEpochMilliseconds(it) } + + // #1350 + DeprecatedInstant::class -> convert { DeprecatedInstant.fromEpochMilliseconds(it) } JavaLocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -537,24 +550,58 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n else -> null } - Instant::class -> when (toClass) { - Long::class -> convert { it.toEpochMilliseconds() } + StdlibInstant::class -> when (toClass) { + Long::class -> convert { it.toEpochMilliseconds() } - LocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone) } + LocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone) } - LocalDate::class -> convert { it.toLocalDate(defaultTimeZone) } + LocalDate::class -> convert { it.toLocalDate(defaultTimeZone) } - LocalTime::class -> convert { it.toLocalTime(defaultTimeZone) } + LocalTime::class -> convert { it.toLocalTime(defaultTimeZone) } - JavaLocalDateTime::class -> convert { + JavaLocalDateTime::class -> convert { it.toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() } - JavaLocalDate::class -> convert { it.toLocalDate(defaultTimeZone).toJavaLocalDate() } + JavaLocalDate::class -> convert { it.toLocalDate(defaultTimeZone).toJavaLocalDate() } + + JavaInstant::class -> convert { it.toJavaInstant() } - JavaInstant::class -> convert { it.toJavaInstant() } + JavaLocalTime::class -> convert { it.toLocalTime(defaultTimeZone).toJavaLocalTime() } - JavaLocalTime::class -> convert { it.toLocalTime(defaultTimeZone).toJavaLocalTime() } + // #1350 + DeprecatedInstant::class -> convert { it.toDeprecatedInstant() } + + else -> null + } + + // #1350 + DeprecatedInstant::class -> when (toClass) { + Long::class -> convert { it.toStdlibInstant().toEpochMilliseconds() } + + LocalDateTime::class -> convert { + it.toStdlibInstant().toLocalDateTime(defaultTimeZone) + } + + LocalDate::class -> convert { it.toStdlibInstant().toLocalDate(defaultTimeZone) } + + LocalTime::class -> convert { it.toStdlibInstant().toLocalTime(defaultTimeZone) } + + JavaLocalDateTime::class -> convert { + it.toStdlibInstant().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() + } + + JavaLocalDate::class -> convert { + it.toStdlibInstant().toLocalDate(defaultTimeZone).toJavaLocalDate() + } + + JavaInstant::class -> convert { it.toStdlibInstant().toJavaInstant() } + + JavaLocalTime::class -> convert { + it.toStdlibInstant().toLocalTime(defaultTimeZone).toJavaLocalTime() + } + + StdlibInstant::class -> convert { it.toStdlibInstant() } else -> null } @@ -570,7 +617,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalTime::class -> convert { it.toKotlinInstant().toLocalTime(defaultTimeZone) } - Instant::class -> convert { it.toKotlinInstant() } + StdlibInstant::class -> convert { it.toKotlinInstant() } JavaLocalDateTime::class -> convert { it.toKotlinInstant().toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() @@ -584,6 +631,11 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n it.toKotlinInstant().toLocalTime(defaultTimeZone).toJavaLocalTime() } + // #1350 + DeprecatedInstant::class -> convert { + it.toKotlinInstant().toDeprecatedInstant() + } + else -> null } @@ -625,13 +677,26 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDateTime::class -> when (toClass) { LocalDate::class -> convert { it.date } + LocalTime::class -> convert { it.time } - Instant::class -> convert { it.toInstant(defaultTimeZone) } + + StdlibInstant::class -> convert { it.toInstant(defaultTimeZone) } + + // #1350 + DeprecatedInstant::class -> convert { + it.toInstant(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.toInstant(defaultTimeZone).toEpochMilliseconds() } + JavaLocalDateTime::class -> convert { it.toJavaLocalDateTime() } + JavaLocalDate::class -> convert { it.date.toJavaLocalDate() } + JavaLocalTime::class -> convert { it.toJavaLocalDateTime().toLocalTime() } + JavaInstant::class -> convert { it.toInstant(defaultTimeZone).toJavaInstant() } + else -> null } @@ -642,10 +707,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDateTime::class -> convert { it.toKotlinLocalDateTime() } - Instant::class -> convert { + StdlibInstant::class -> convert { it.toKotlinLocalDateTime().toInstant(defaultTimeZone) } + // #1350 + DeprecatedInstant::class -> convert { + it.toKotlinLocalDateTime().toInstant(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.toKotlinLocalDateTime().toInstant(defaultTimeZone).toEpochMilliseconds() } @@ -663,11 +733,22 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDate::class -> when (toClass) { LocalDateTime::class -> convert { it.atTime(0, 0) } - Instant::class -> convert { it.atStartOfDayIn(defaultTimeZone) } + + StdlibInstant::class -> convert { it.atStartOfDayIn(defaultTimeZone) } + + // #1350 + DeprecatedInstant::class -> convert { + it.atStartOfDayIn(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.atStartOfDayIn(defaultTimeZone).toEpochMilliseconds() } + JavaLocalDate::class -> convert { it.toJavaLocalDate() } + JavaLocalDateTime::class -> convert { it.atTime(0, 0).toJavaLocalDateTime() } + JavaInstant::class -> convert { it.atStartOfDayIn(defaultTimeZone).toJavaInstant() } + else -> null } @@ -676,10 +757,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n LocalDateTime::class -> convert { it.atTime(0, 0).toKotlinLocalDateTime() } - Instant::class -> convert { + StdlibInstant::class -> convert { it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone) } + // #1350 + DeprecatedInstant::class -> convert { + it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone).toDeprecatedInstant() + } + Long::class -> convert { it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone).toEpochMilliseconds() } @@ -715,15 +801,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n } internal fun Long.toLocalDateTime(zone: TimeZone = defaultTimeZone) = - Instant.fromEpochMilliseconds(this).toLocalDateTime(zone) + StdlibInstant.fromEpochMilliseconds(this).toLocalDateTime(zone) internal fun Long.toLocalDate(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).date internal fun Long.toLocalTime(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).time -internal fun Instant.toLocalDate(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).date +internal fun StdlibInstant.toLocalDate(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).date -internal fun Instant.toLocalTime(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).time +internal fun StdlibInstant.toLocalTime(zone: TimeZone = defaultTimeZone) = toLocalDateTime(zone).time internal val defaultTimeZone get() = TimeZone.currentSystemDefault() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt index 827df998fd..7d7fdbd962 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt @@ -1,12 +1,10 @@ package org.jetbrains.kotlinx.dataframe.impl.api import io.github.oshai.kotlinlogging.KotlinLogging -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime -import kotlinx.datetime.format.DateTimeComponents -import kotlinx.datetime.toKotlinInstant +import kotlinx.datetime.toDeprecatedInstant import kotlinx.datetime.toKotlinLocalDate import kotlinx.datetime.toKotlinLocalDateTime import kotlinx.datetime.toKotlinLocalTime @@ -56,6 +54,7 @@ import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf import kotlin.time.Duration +import kotlin.time.toKotlinInstant import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid import java.time.Duration as JavaDuration @@ -63,6 +62,8 @@ import java.time.Instant as JavaInstant import java.time.LocalDate as JavaLocalDate import java.time.LocalDateTime as JavaLocalDateTime import java.time.LocalTime as JavaLocalTime +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant private val logger = KotlinLogging.logger { } @@ -142,7 +143,9 @@ internal object Parsers : GlobalParserOptions { override val skipTypes: Set get() = skipTypesSet - override var parseExperimentalUuid: Boolean = false + override var parseExperimentalUuid by Delegates.notNull() + + override var parseExperimentalInstant by Delegates.notNull() override fun addDateTimePattern(pattern: String) { formatters.add(DateTimeFormatter.ofPattern(pattern)) @@ -183,6 +186,7 @@ internal object Parsers : GlobalParserOptions { useFastDoubleParser = true parseExperimentalUuid = false + parseExperimentalInstant = false _locale = null nullStrings.addAll(listOf("null", "NULL", "NA", "N/A")) } @@ -211,14 +215,8 @@ internal object Parsers : GlobalParserOptions { } } - private fun String.toInstantOrNull(): Instant? = - // low chance throwing exception, thanks to using parseOrNull instead of parse - catchSilent { - // Default format used by Instant.parse - DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET - .parseOrNull(this) - ?.toInstantUsingOffset() - } + private fun String.toInstantOrNull(): StdlibInstant? = + StdlibInstant.parseOrNull(this) // fallback on the java instant to catch things like "2022-01-23T04:29:60", a.k.a. leap seconds ?: toJavaInstantOrNull()?.toKotlinInstant() @@ -305,7 +303,7 @@ internal object Parsers : GlobalParserOptions { } private fun String.toDurationOrNull(): Duration? = - if (Duration.canParse(this)) { + if (Duration.canParse(this)) { // TODO, migrate to `Duration.parseOrNull()` in Kotlin 2.3.0+ catchSilent { Duration.parse(this) } // will likely succeed } else { null @@ -439,12 +437,24 @@ internal object Parsers : GlobalParserOptions { stringParser { it.toIntOrNull() }, // Long stringParser { it.toLongOrNull() }, + // kotlin.time.Instant + stringParserWithOptions { + val parseExperimentalInstant = it?.parseExperimentalInstant ?: this.parseExperimentalInstant + val parser = { it: String -> + if (parseExperimentalInstant) { + it.toInstantOrNull() + } else { + null + } + } + parser + }, // kotlinx.datetime.Instant - stringParser { - it.toInstantOrNull() + stringParser { + it.toInstantOrNull()?.toDeprecatedInstant() }, // java.time.Instant, will be skipped if kotlinx.datetime.Instant is already checked - stringParser(coveredBy = setOf(typeOf())) { + stringParser(coveredBy = setOf(typeOf())) { it.toJavaInstantOrNull() }, // kotlinx.datetime.LocalDateTime diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt index 9d213b2c0f..948525a9ad 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/toDataFrame.kt @@ -37,6 +37,8 @@ import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField import kotlin.reflect.typeOf +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant // non-standard value types (not supertypes, but exact types) private val valueTypes = setOf( @@ -52,7 +54,8 @@ private val valueTypes = setOf( kotlin.time.Duration::class, kotlinx.datetime.LocalDate::class, kotlinx.datetime.LocalDateTime::class, - kotlinx.datetime.Instant::class, + DeprecatedInstant::class, + StdlibInstant::class, kotlinx.datetime.TimeZone::class, kotlinx.datetime.DateTimePeriod::class, kotlinx.datetime.DateTimeUnit::class, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt index fc370459af..3604b8b911 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt @@ -1,6 +1,5 @@ package org.jetbrains.kotlinx.dataframe.io -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -20,6 +19,10 @@ import org.jetbrains.kotlinx.dataframe.util.APACHE_CSV import org.jetbrains.kotlinx.dataframe.util.AS_URL import org.jetbrains.kotlinx.dataframe.util.AS_URL_IMPORT import org.jetbrains.kotlinx.dataframe.util.AS_URL_REPLACE +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_DEPRECATED_INSTANT +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_DEPRECATED_INSTANT_REPLACE +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_INSTANT +import org.jetbrains.kotlinx.dataframe.util.COL_TYPE_INSTANT_REPLACE import org.jetbrains.kotlinx.dataframe.util.DF_READ_NO_CSV import org.jetbrains.kotlinx.dataframe.util.DF_READ_NO_CSV_REPLACE import org.jetbrains.kotlinx.dataframe.util.READ_CSV @@ -59,6 +62,8 @@ import kotlin.reflect.KClass import kotlin.reflect.KType import kotlin.reflect.typeOf import kotlin.time.Duration +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant @Deprecated(message = APACHE_CSV, level = DeprecationLevel.WARNING) public class CSV(private val delimiter: Char = ',') : SupportedDataFrameFormat { @@ -329,12 +334,28 @@ public enum class ColType { LocalTime, LocalDateTime, String, + + @Deprecated( + message = COL_TYPE_INSTANT, + replaceWith = ReplaceWith(COL_TYPE_INSTANT_REPLACE), + level = DeprecationLevel.ERROR, + ) Instant, Duration, Url, JsonArray, JsonObject, Char, + + @Deprecated( + message = COL_TYPE_DEPRECATED_INSTANT, + replaceWith = ReplaceWith(COL_TYPE_DEPRECATED_INSTANT_REPLACE), + level = DeprecationLevel.WARNING, + ) + DeprecatedInstant, + + /** Temporary, will be renamed to [Instant] in 1.1+ */ + StdlibInstant, ; public companion object { @@ -352,21 +373,44 @@ public fun ColType.toType(): KClass<*> = toKType().classifier as KClass<*> public fun ColType.toKType(): KType = when (this) { ColType.Int -> typeOf() + ColType.Long -> typeOf() + ColType.Double -> typeOf() + ColType.Boolean -> typeOf() + ColType.BigDecimal -> typeOf() + ColType.BigInteger -> typeOf() + ColType.LocalDate -> typeOf() + ColType.LocalTime -> typeOf() + ColType.LocalDateTime -> typeOf() + ColType.String -> typeOf() - ColType.Instant -> typeOf() + + ColType.DeprecatedInstant -> typeOf() + + ColType.StdlibInstant -> typeOf() + ColType.Duration -> typeOf() + ColType.Url -> typeOf() + ColType.JsonArray -> typeOf>() + ColType.JsonObject -> typeOf>() + ColType.Char -> typeOf() + + else -> { + // can't reference ColType.Instant directly because of the deprecation cycle + require(this.name == "Instant") { "Unknown column type: $this" } + typeOf() + } } @Deprecated( diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt index e65f29c732..7f10091200 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt @@ -125,6 +125,18 @@ internal const val COLS_TO_ALL_REPLACE = "this.all()" internal const val COLS_TO_ALL_COLS = "This `cols()` overload will be removed in favor of `allCols()`. $MESSAGE_1_0" internal const val COLS_TO_ALL_COLS_REPLACE = "this.allCols()" +internal const val CONVERT_TO_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Either migrate to kotlin.time.Instant and use convertToStdlibInstant() or use convertToDeprecatedInstant(). $MESSAGE_1_0 and migrated to kotlin.time.Instant in 1.1." +internal const val CONVERT_TO_INSTANT_REPLACE = "this.convertToDeprecatedInstant()" + +internal const val TO_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Either migrate to kotlin.time.Instant and use toStdlibInstant() or use toDeprecatedInstant(). $MESSAGE_1_0 and migrated to kotlin.time.Instant in 1.1." +internal const val TO_INSTANT_REPLACE = "this.toDeprecatedInstant()" + +internal const val COL_TYPE_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Either migrate to kotlin.time.Instant and use ColType.StdlibInstant or use ColType.DeprecatedInstant. $MESSAGE_1_0 and migrated to kotlin.time.Instant in 1.1." +internal const val COL_TYPE_INSTANT_REPLACE = "ColType.DeprecatedInstant" + // endregion // region WARNING in 1.0, ERROR in 1.1 @@ -202,6 +214,19 @@ internal const val GENERATE_CODE_REPLACE2 = internal const val GENERATE_INTERFACES = "This function is just here for binary compatibility. $MESSAGE_1_1" internal const val UNIFIED_SIMILAR_CS_API = "Deprecated duplicated functionality. $MESSAGE_1_1" + +internal const val CONVERT_TO_DEPRECATED_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Migrate to kotlin.time.Instant and use convertToStdlibInstant() at your own pace. $MESSAGE_1_1" +internal const val CONVERT_TO_DEPRECATED_INSTANT_REPLACE = "this.convertToStdlibInstant()" + +internal const val TO_DEPRECATED_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Migrate to kotlin.time.Instant and use toStdlibInstant() at your own pace. $MESSAGE_1_1" +internal const val TO_DEPRECATED_INSTANT_REPLACE = "this.toStdlibInstant()" + +internal const val COL_TYPE_DEPRECATED_INSTANT = + "kotlinx.datetime.Instant is deprecated in favor of kotlin.time.Instant. Migrate to kotlin.time.Instant and use Coltype.StdlibInstant at your own pace. $MESSAGE_1_1" +internal const val COL_TYPE_DEPRECATED_INSTANT_REPLACE = "ColType.StdlibInstant" + // endregion // region keep across releases diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt index 0350b8ab71..21a7ab55c6 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt @@ -4,15 +4,14 @@ import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import kotlinx.datetime.DateTimeUnit -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.datetime.Month import kotlinx.datetime.format.DateTimeComponents import kotlinx.datetime.plus -import kotlinx.datetime.toJavaInstant -import kotlinx.datetime.toKotlinInstant +import kotlinx.datetime.toDeprecatedInstant +import kotlinx.datetime.toStdlibInstant import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.impl.api.Parsers import org.jetbrains.kotlinx.dataframe.impl.catchSilent @@ -29,10 +28,14 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.nanoseconds import kotlin.time.Duration.Companion.seconds +import kotlin.time.toJavaInstant +import kotlin.time.toKotlinInstant import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid import java.time.Duration as JavaDuration import java.time.Instant as JavaInstant +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant class ParseTests { @Test @@ -48,14 +51,14 @@ class ParseTests { parsed.type() shouldBe typeOf() with(parsed[0]) { month shouldBe Month.JANUARY - dayOfMonth shouldBe 1 + day shouldBe 1 year shouldBe 2020 } date.convertToLocalDate(pattern) shouldBe parsed with(date.toDataFrame()) { - convert { date }.toLocalDate(pattern)[date] shouldBe parsed - parse(ParserOptions(dateTimePattern = pattern))[date] shouldBe parsed + convert { date }.toLocalDate(pattern)[date.name] shouldBe parsed + parse(ParserOptions(dateTimePattern = pattern))[date.name] shouldBe parsed } DataFrame.parser.addDateTimePattern(pattern) @@ -83,7 +86,7 @@ class ParseTests { parsed.type() shouldBe typeOf() with(parsed[0]) { month shouldBe Month.JUNE - dayOfMonth shouldBe 3 + day shouldBe 3 year shouldBe 2008 hour shouldBe 13 minute shouldBe 5 @@ -92,8 +95,8 @@ class ParseTests { dateTime.convertToLocalDateTime(pattern, locale) shouldBe parsed with(dateTime.toDataFrame()) { - convert { dateTime }.toLocalDateTime(pattern)[dateTime] shouldBe parsed - parse(ParserOptions(dateTimePattern = pattern))[dateTime] shouldBe parsed + convert { dateTime }.toLocalDateTime(pattern)[dateTime.name] shouldBe parsed + parse(ParserOptions(dateTimePattern = pattern))[dateTime.name] shouldBe parsed } DataFrame.parser.addDateTimePattern(pattern) @@ -154,19 +157,25 @@ class ParseTests { @Test fun `parse instant`() { - columnOf("2022-01-23T04:29:40Z").parse().type shouldBe typeOf() - columnOf("2022-01-23T04:29:40+01:00").parse().type shouldBe typeOf() + columnOf("2022-01-23T04:29:40Z").parse().type shouldBe typeOf() + columnOf("2022-01-23T04:29:40+01:00").parse().type shouldBe typeOf() + + val options = ParserOptions(parseExperimentalInstant = true) + columnOf("2022-01-23T04:29:40Z").parse(options).type shouldBe typeOf() + columnOf("2022-01-23T04:29:40+01:00").parse(options).type shouldBe typeOf() columnOf("2022-01-23T04:29:40").parse().type shouldBe typeOf() } @Test fun `can parse instants`() { - val instantParser = Parsers[typeOf()]!!.applyOptions(null) + val deprecatedInstantParser = Parsers[typeOf()]!!.applyOptions(null) + val stdlibInstantParser = Parsers[typeOf()]!! + .applyOptions(ParserOptions(parseExperimentalInstant = true)) val javaInstantParser = Parsers[typeOf()]!!.applyOptions(null) // from the kotlinx-datetime tests, java instants treat leap seconds etc. like this - fun parseInstantLikeJavaDoesOrNull(input: String): Instant? = + fun parseInstantLikeJavaDoesOrNull(input: String): StdlibInstant? = catchSilent { DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET.parseOrNull(input)?.apply { when { @@ -187,21 +196,35 @@ class ParseTests { for (second in listOf(0..5, 58..62).flatten()) { val input = "2020-03-16T$hour:${formatTwoDigits(minute)}:${formatTwoDigits(second)}Z" - val myParserRes = instantParser(input) as Instant? - val myJavaParserRes = javaInstantParser(input) as JavaInstant? - val instantRes = catchSilent { Instant.parse(input) } - val instantLikeJava = parseInstantLikeJavaDoesOrNull(input) - val javaInstantRes = catchSilent { JavaInstant.parse(input) } + val deprecatedParserRes = deprecatedInstantParser(input) as DeprecatedInstant? + val javaParserRes = javaInstantParser(input) as JavaInstant? + val stdlibParserRes = stdlibInstantParser(input) as StdlibInstant? - // our parser has a fallback mechanism built in, like this - myParserRes shouldBe (instantRes ?: javaInstantRes?.toKotlinInstant()) - myParserRes shouldBe instantLikeJava + val deprecatedInstantRes = catchSilent { DeprecatedInstant.parse(input) } + val stdlibInstantRes = catchSilent { StdlibInstant.parse(input) } - myJavaParserRes shouldBe javaInstantRes + val stdlibInstantLikeJava = parseInstantLikeJavaDoesOrNull(input) + val javaInstantRes = catchSilent { JavaInstant.parse(input) } + + javaParserRes?.toKotlinInstant() shouldBe stdlibParserRes - myParserRes?.toJavaInstant() shouldBe instantLikeJava?.toJavaInstant() - instantLikeJava?.toJavaInstant() shouldBe myJavaParserRes - myJavaParserRes shouldBe javaInstantRes + // our parser has a fallback mechanism built in, like this + deprecatedParserRes shouldBe ( + deprecatedInstantRes ?: javaInstantRes?.toKotlinInstant()?.toDeprecatedInstant() + ) + deprecatedParserRes shouldBe stdlibInstantLikeJava?.toDeprecatedInstant() + + stdlibParserRes shouldBe (stdlibInstantRes ?: javaInstantRes?.toKotlinInstant()) + stdlibParserRes shouldBe stdlibInstantLikeJava + + javaParserRes shouldBe javaInstantRes + + deprecatedParserRes?.toStdlibInstant()?.toJavaInstant() shouldBe ( + stdlibInstantLikeJava?.toJavaInstant() + ) + stdlibParserRes?.toJavaInstant() shouldBe stdlibInstantLikeJava?.toJavaInstant() + stdlibInstantLikeJava?.toJavaInstant() shouldBe javaParserRes + javaParserRes shouldBe javaInstantRes } } } diff --git a/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt b/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt index ff3e7ea064..194e5dec3f 100644 --- a/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt +++ b/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt @@ -237,7 +237,7 @@ internal class ArrowWriterImpl( is DateDayVector -> column.convertToLocalDate() .forEachIndexed { i, value -> - value?.also { vector.set(i, value.toEpochDays()) } + value?.also { vector.set(i, value.toEpochDays().toInt()) } ?: vector.setNull(i) } diff --git a/dataframe-arrow/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowKtTest.kt b/dataframe-arrow/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowKtTest.kt index 86cc63cfc2..d85109429b 100644 --- a/dataframe-arrow/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowKtTest.kt +++ b/dataframe-arrow/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowKtTest.kt @@ -7,7 +7,6 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.UtcOffset import kotlinx.datetime.toInstant -import kotlinx.datetime.toJavaInstant import org.apache.arrow.memory.RootAllocator import org.apache.arrow.vector.TimeStampMicroVector import org.apache.arrow.vector.TimeStampMilliVector @@ -55,6 +54,7 @@ import java.nio.file.FileSystems import java.sql.DriverManager import java.util.Locale import kotlin.reflect.typeOf +import kotlin.time.toJavaInstant internal class ArrowKtTest { diff --git a/dataframe-csv/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt b/dataframe-csv/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt index 3ef98a4f96..95ce6c4049 100644 --- a/dataframe-csv/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt +++ b/dataframe-csv/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt @@ -19,7 +19,6 @@ import io.deephaven.csv.parsers.Parser import io.deephaven.csv.parsers.Parsers import io.deephaven.csv.reading.CsvReader import io.deephaven.csv.util.CsvReaderException -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -49,6 +48,8 @@ import kotlin.reflect.KType import kotlin.reflect.full.withNullability import kotlin.reflect.typeOf import kotlin.time.Duration +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant /** * Implementation to read delimiter-separated data from an [InputStream] based on the Deephaven CSV library. @@ -386,7 +387,8 @@ internal fun KType.toColType(): ColType = typeOf() -> ColType.LocalTime typeOf() -> ColType.LocalDateTime typeOf() -> ColType.String - typeOf() -> ColType.Instant + typeOf() -> ColType.DeprecatedInstant + typeOf() -> ColType.StdlibInstant typeOf() -> ColType.Duration typeOf() -> ColType.Url typeOf>() -> ColType.JsonArray diff --git a/dataframe-csv/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt b/dataframe-csv/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt index 153e26553f..b81f707bfd 100644 --- a/dataframe-csv/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt +++ b/dataframe-csv/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt @@ -6,7 +6,6 @@ import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.collections.shouldContainInOrder import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import org.intellij.lang.annotations.Language @@ -36,6 +35,8 @@ import java.util.Locale import java.util.zip.GZIPInputStream import kotlin.reflect.KClass import kotlin.reflect.typeOf +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant // can be enabled for showing logs for these tests private const val SHOW_LOGS = false @@ -771,8 +772,8 @@ class DelimCsvTsvTests { // use DFs parsers by default for datetime-like columns val df1 = DataFrame.readCsvStr(csvContent) df1["with_timezone_offset"].let { - it.type() shouldBe typeOf() - it[0] shouldBe Instant.parse("2024-12-12T13:00:00+01:00") + it.type() shouldBe typeOf() + it[0] shouldBe DeprecatedInstant.parse("2024-12-12T13:00:00+01:00") } df1["without_timezone_offset"].let { it.type() shouldBe typeOf() @@ -796,6 +797,27 @@ class DelimCsvTsvTests { } } + @Test + fun `test parsing kotlin-time-Instant`() { + @Language("csv") + val csvContent = + """ + with_timezone_offset,without_timezone_offset + 2024-12-12T13:00:00+01:00,2024-12-12T13:00:00 + """.trimIndent() + + DataFrame.parser.parseExperimentalInstant = true + + // use DFs parsers by default for datetime-like columns + val df1 = DataFrame.readCsvStr(csvContent) + df1["with_timezone_offset"].let { + it.type() shouldBe typeOf() + it[0] shouldBe StdlibInstant.parse("2024-12-12T13:00:00+01:00") + } + + DataFrame.parser.resetToDefault() + } + @Test fun `json dependency test`() { val df = dataFrameOf("firstName", "lastName")( diff --git a/dataframe-csv/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt b/dataframe-csv/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt index 4324d12998..5bb883fb08 100644 --- a/dataframe-csv/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt +++ b/dataframe-csv/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/readDelim.kt @@ -19,7 +19,6 @@ import io.deephaven.csv.parsers.Parser import io.deephaven.csv.parsers.Parsers import io.deephaven.csv.reading.CsvReader import io.deephaven.csv.util.CsvReaderException -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -66,6 +65,8 @@ import kotlin.reflect.KType import kotlin.reflect.full.withNullability import kotlin.reflect.typeOf import kotlin.time.Duration +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant /** * Implementation to read delimiter-separated data from an [InputStream] based on the Deephaven CSV library. @@ -347,7 +348,8 @@ internal fun KType.toColType(): ColType = typeOf() -> ColType.LocalTime typeOf() -> ColType.LocalDateTime typeOf() -> ColType.String - typeOf() -> ColType.Instant + typeOf() -> ColType.DeprecatedInstant + typeOf() -> ColType.StdlibInstant typeOf() -> ColType.Duration typeOf() -> ColType.Url typeOf>() -> ColType.JsonArray diff --git a/dataframe-csv/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt b/dataframe-csv/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt index 153e26553f..b81f707bfd 100644 --- a/dataframe-csv/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt +++ b/dataframe-csv/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt @@ -6,7 +6,6 @@ import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.collections.shouldContainInOrder import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe -import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import org.intellij.lang.annotations.Language @@ -36,6 +35,8 @@ import java.util.Locale import java.util.zip.GZIPInputStream import kotlin.reflect.KClass import kotlin.reflect.typeOf +import kotlin.time.Instant as StdlibInstant +import kotlinx.datetime.Instant as DeprecatedInstant // can be enabled for showing logs for these tests private const val SHOW_LOGS = false @@ -771,8 +772,8 @@ class DelimCsvTsvTests { // use DFs parsers by default for datetime-like columns val df1 = DataFrame.readCsvStr(csvContent) df1["with_timezone_offset"].let { - it.type() shouldBe typeOf() - it[0] shouldBe Instant.parse("2024-12-12T13:00:00+01:00") + it.type() shouldBe typeOf() + it[0] shouldBe DeprecatedInstant.parse("2024-12-12T13:00:00+01:00") } df1["without_timezone_offset"].let { it.type() shouldBe typeOf() @@ -796,6 +797,27 @@ class DelimCsvTsvTests { } } + @Test + fun `test parsing kotlin-time-Instant`() { + @Language("csv") + val csvContent = + """ + with_timezone_offset,without_timezone_offset + 2024-12-12T13:00:00+01:00,2024-12-12T13:00:00 + """.trimIndent() + + DataFrame.parser.parseExperimentalInstant = true + + // use DFs parsers by default for datetime-like columns + val df1 = DataFrame.readCsvStr(csvContent) + df1["with_timezone_offset"].let { + it.type() shouldBe typeOf() + it[0] shouldBe StdlibInstant.parse("2024-12-12T13:00:00+01:00") + } + + DataFrame.parser.resetToDefault() + } + @Test fun `json dependency test`() { val df = dataFrameOf("firstName", "lastName")( diff --git a/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/DataFrameJupyterTest.kt b/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/DataFrameJupyterTest.kt index 8c009164c0..fe350db010 100644 --- a/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/DataFrameJupyterTest.kt +++ b/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/DataFrameJupyterTest.kt @@ -7,7 +7,11 @@ import org.jetbrains.kotlinx.jupyter.testkit.ReplProvider abstract class DataFrameJupyterTest : JupyterReplTestCase( ReplProvider.forLibrariesTesting( - setOf("dataframe", "dataframe-jupyter"), + libraries = setOf("dataframe", "dataframe-jupyter"), + extraCompilerArguments = listOf( + "-Xopt-in=kotlin.time.ExperimentalTime", + "-Xopt-in=kotlin.uuid.ExperimentalUuidApi", + ), ), ) diff --git a/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/ReplProviderExtraCompilerArguments.kt b/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/ReplProviderExtraCompilerArguments.kt new file mode 100644 index 0000000000..846faa215e --- /dev/null +++ b/dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/ReplProviderExtraCompilerArguments.kt @@ -0,0 +1,55 @@ +package org.jetbrains.kotlinx.dataframe.jupyter + +import org.jetbrains.kotlinx.jupyter.api.EmbeddedKernelRunMode +import org.jetbrains.kotlinx.jupyter.config.DefaultKernelLoggerFactory +import org.jetbrains.kotlinx.jupyter.config.defaultRepositoriesCoordinates +import org.jetbrains.kotlinx.jupyter.libraries.LibraryResolver +import org.jetbrains.kotlinx.jupyter.libraries.createLibraryHttpUtil +import org.jetbrains.kotlinx.jupyter.repl.ReplForJupyter +import org.jetbrains.kotlinx.jupyter.repl.creating.createRepl +import org.jetbrains.kotlinx.jupyter.repl.embedded.NoOpInMemoryReplResultsHolder +import org.jetbrains.kotlinx.jupyter.testkit.ClasspathLibraryResolver +import org.jetbrains.kotlinx.jupyter.testkit.ReplProvider +import org.jetbrains.kotlinx.jupyter.testkit.ToEmptyLibraryResolver + +/** Mirrors [ReplProvider.forLibrariesTesting] but `extraCompilerArguments` to set opt-in's. */ +@Suppress("unused") +fun ReplProvider.Companion.forLibrariesTesting( + libraries: Collection, + extraCompilerArguments: List = emptyList(), +): ReplProvider = + withDefaultClasspathResolution( + shouldResolveToEmpty = { it in libraries }, + extraCompilerArguments = extraCompilerArguments, + ) + +private val httpUtil = createLibraryHttpUtil(DefaultKernelLoggerFactory) + +fun withDefaultClasspathResolution( + shouldResolve: (String?) -> Boolean = { true }, + shouldResolveToEmpty: (String?) -> Boolean = { false }, + extraCompilerArguments: List = emptyList(), +) = ReplProvider { classpath -> + val resolver = + run { + var res: LibraryResolver = ClasspathLibraryResolver(httpUtil.libraryDescriptorsManager, null, shouldResolve) + res = ToEmptyLibraryResolver(res, shouldResolveToEmpty) + res + } + + createRepl( + httpUtil = httpUtil, + scriptClasspath = classpath, + kernelRunMode = EmbeddedKernelRunMode, + mavenRepositories = defaultRepositoriesCoordinates, + libraryResolver = resolver, + inMemoryReplResultsHolder = NoOpInMemoryReplResultsHolder, + extraCompilerArguments = extraCompilerArguments, + ).apply { + initializeWithCurrentClasspath() + } +} + +private fun ReplForJupyter.initializeWithCurrentClasspath() { + eval { librariesScanner.addLibrariesFromClassLoader(currentClassLoader, this, notebook) } +} diff --git a/docs/StardustDocs/resources/api/generate_docs/notebook_test_generate_docs_1.html b/docs/StardustDocs/resources/api/generate_docs/notebook_test_generate_docs_1.html index 8ca7a8ece0..231481e43f 100644 --- a/docs/StardustDocs/resources/api/generate_docs/notebook_test_generate_docs_1.html +++ b/docs/StardustDocs/resources/api/generate_docs/notebook_test_generate_docs_1.html @@ -177,7 +177,7 @@ -
+

@@ -458,23 +458,23 @@ /**/ /**/ /**/ -call_DataFrame(function() { DataFrame.renderTable(838860800) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726656) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/api/rename/notebook_test_rename_3.html b/docs/StardustDocs/resources/api/rename/notebook_test_rename_3.html index d9d5649f29..7a7c65ddfa 100644 --- a/docs/StardustDocs/resources/api/rename/notebook_test_rename_3.html +++ b/docs/StardustDocs/resources/api/rename/notebook_test_rename_3.html @@ -177,7 +177,7 @@ -
+

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "ColumnA", children: [], rightAlign: true, values: ["1","2"] }, { name: "column_b", children: [], rightAlign: false, values: ["a","b"] }, { name: "COLUMN-C", children: [], rightAlign: false, values: ["true","false"] }, -], id: 838860803, rootId: 838860803, totalRows: 2 } ) }); +], id: -1526726650, rootId: -1526726650, totalRows: 2 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860803) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726650) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/api/rename/notebook_test_rename_4.html b/docs/StardustDocs/resources/api/rename/notebook_test_rename_4.html index 06cd98bfdb..5656068034 100644 --- a/docs/StardustDocs/resources/api/rename/notebook_test_rename_4.html +++ b/docs/StardustDocs/resources/api/rename/notebook_test_rename_4.html @@ -177,7 +177,7 @@ -
+

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "columnA", children: [], rightAlign: true, values: ["1","2"] }, { name: "column_b", children: [], rightAlign: false, values: ["a","b"] }, { name: "columnC", children: [], rightAlign: false, values: ["true","false"] }, -], id: 838860804, rootId: 838860804, totalRows: 2 } ) }); +], id: -1526726649, rootId: -1526726649, totalRows: 2 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860804) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726649) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/api/rename/notebook_test_rename_5.html b/docs/StardustDocs/resources/api/rename/notebook_test_rename_5.html index e7dea84bae..85959e4c5f 100644 --- a/docs/StardustDocs/resources/api/rename/notebook_test_rename_5.html +++ b/docs/StardustDocs/resources/api/rename/notebook_test_rename_5.html @@ -177,7 +177,7 @@ -
+

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "columnA", children: [], rightAlign: true, values: ["1","2"] }, { name: "columnB", children: [], rightAlign: false, values: ["a","b"] }, { name: "columnC", children: [], rightAlign: false, values: ["true","false"] }, -], id: 838860805, rootId: 838860805, totalRows: 2 } ) }); +], id: -1526726648, rootId: -1526726648, totalRows: 2 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860805) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726648) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_10.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_10.html index bb0c7bc1d7..b664666c6c 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_10.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_10.html @@ -177,7 +177,7 @@ -
+

... showing only top 20 of 24 rows

@@ -461,10 +461,10 @@ { name: "starsCount", children: [], rightAlign: true, values: ["6120","1241","12926","1066","39402","1737","5688","1074","1181","1072","1110","1058","1815","1017","7101","2424","2836","2628","6059","1133"] }, { name: "\">topics", children: [], rightAlign: false, values: ["[ideavim, intellij, intellij-pl..., ...]","[domain-specific-language, dsl]","[code-editor, ide, intellij, i..., i...]","[intellij-idea, intellij-plugin, scala]","[compiler, gradle-plugin, intel..., ...]","[]","[dao, kotlin, orm, sql]","[kotlin]","[gitignore, ignore-files, intellij, ...]","[]","[]","[gradle, gradle-intellij-plugin, ...]","[sprite, svg, svg-sprite, svg-s..., ...]","[hacktoberfest, jetbrains, plugin, ...]","[c, compiler, kotlin, llvm, objective-c]","[create-react-app, jetbrains-ui, ...]","[components, jetbrains-ui, react]","[]","[coding-font, font, ligatures, ...]","[intellij, intellij-idea, intel..., ...]"] }, { name: "isIntellij", children: [], rightAlign: false, values: ["true","false","true","true","false","true","false","false","true","false","false","true","false","false","false","false","false","false","false","true"] }, -], id: 838860812, rootId: 838860812, totalRows: 24 } ) }); +], id: -1526726641, rootId: -1526726641, totalRows: 24 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860812) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726641) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_11.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_11.html index d131348803..9616ab9286 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_11.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_11.html @@ -177,7 +177,7 @@ -
+

@@ -458,8 +458,8 @@ /**/ /**/ /**/ -call_DataFrame(function() { DataFrame.renderTable(838860813) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726640) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_12.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_12.html index 505bd23373..8dfd6666c6 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_12.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_12.html @@ -177,7 +177,7 @@ -
+

@@ -459,10 +459,10 @@ /**/ -call_DataFrame(function() { DataFrame.renderTable(838860816) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726637) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_13.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_13.html index 96577a3995..04442589dd 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_13.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_13.html @@ -177,7 +177,7 @@ -
+

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "isIntellij", children: [], rightAlign: false, values: ["true","false"] }, { name: "sumStars", children: [], rightAlign: true, values: ["25221","85392"] }, { name: "maxStars", children: [], rightAlign: true, values: ["12926","39402"] }, -], id: 838860817, rootId: 838860817, totalRows: 2 } ) }); +], id: -1526726636, rootId: -1526726636, totalRows: 2 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860817) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726636) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_14.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_14.html index e3064b19df..b2bdf86953 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_14.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_14.html @@ -177,7 +177,7 @@ -
+

@@ -461,10 +461,10 @@ { name: "starsCount", children: [], rightAlign: true, values: ["39402","12926","7101","6805","6120","6059","5688","2836","2628","2424"] }, { name: "\">topics", children: [], rightAlign: false, values: ["[compiler, gradle-plugin, intel..., ...]","[code-editor, ide, intellij, i..., i...]","[c, compiler, kotlin, llvm, objective-c]","[android, awt, compose, declara..., ...]","[ideavim, intellij, intellij-pl..., ...]","[coding-font, font, ligatures, ...]","[dao, kotlin, orm, sql]","[components, jetbrains-ui, react]","[]","[create-react-app, jetbrains-ui, ...]"] }, { name: "isIntellij", children: [], rightAlign: false, values: ["false","true","false","false","true","false","false","false","false","false"] }, -], id: 838860818, rootId: 838860818, totalRows: 10 } ) }); +], id: -1526726635, rootId: -1526726635, totalRows: 10 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860818) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726635) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_3.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_3.html index f7c38dab3a..79ee06da0c 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_3.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_3.html @@ -177,7 +177,7 @@ -
+

... showing only top 20 of 562 rows

@@ -462,10 +462,10 @@ { name: "stargazers_count", children: [], rightAlign: true, values: ["23","115","290","6120","5","8","47","11","41","534","6","218","1241","12926","39","118","1066","125","27","39402"] }, { name: "topics", children: [], rightAlign: false, values: ["[]","[jetbrains, jetbrains-youtrack, youtr...","[]","[ideavim, intellij, intellij-platform...","[]","[]","[]","[]","[nuget, nuget-feed, teamcity, teamcit...","[]","[]","[]","[domain-specific-language, dsl]","[code-editor, ide, intellij, intellij...","[c-sharp, teamcity, teamcity-service-...","[]","[intellij-idea, intellij-plugin, scala]","[]","[]","[compiler, gradle-plugin, intellij-pl..."] }, { name: "watchers", children: [], rightAlign: true, values: ["23","115","290","6120","5","8","47","11","41","534","6","218","1241","12926","39","118","1066","125","27","39402"] }, -], id: 838860806, rootId: 838860806, totalRows: 562 } ) }); +], id: -1526726647, rootId: -1526726647, totalRows: 562 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860806) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726647) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_4.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_4.html index a93f87ac5b..94eacf2e84 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_4.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_4.html @@ -177,7 +177,7 @@ -
+

@@ -467,14 +467,14 @@ { name: "mean", children: [], rightAlign: true, values: ["null","null","244.759786","null","244.759786"] }, { name: "std", children: [], rightAlign: true, values: ["null","null","1862.801982","null","1862.801982"] }, { name: "?\">min", children: [], rightAlign: false, values: ["JetBrains/Android-Tuts-Samples","null","0","[2d, graphics, java, skia]","0"] }, -{ name: "?\">p25", children: [], rightAlign: false, values: ["JetBrains/eslint-plugin-angular","null","2","[]","2"] }, -{ name: "?\">median", children: [], rightAlign: false, values: ["JetBrains/lightbeam","null","8","[]","8"] }, -{ name: "?\">p75", children: [], rightAlign: false, values: ["JetBrains/teamcity-bazel-plugin","null","48","[awt, swing]","48"] }, +{ name: "?\">p25", children: [], rightAlign: false, values: ["JetBrains/eslint-config","null","2.0","[]","2.0"] }, +{ name: "?\">median", children: [], rightAlign: false, values: ["JetBrains/lightbeam","null","8.0","[]","8.0"] }, +{ name: "?\">p75", children: [], rightAlign: false, values: ["JetBrains/teamcity-bitbucket-issues","null","48.0","[awt, swing]","48.0"] }, { name: "?\">max", children: [], rightAlign: false, values: ["JetBrains/ztools","null","39402","[youtrack, youtrack-workflow]","39402"] }, -], id: 838860807, rootId: 838860807, totalRows: 5 } ) }); +], id: -1526726646, rootId: -1526726646, totalRows: 5 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860807) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726646) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_5.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_5.html index 3c4d788827..ad4e75413b 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_5.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_5.html @@ -177,7 +177,7 @@ -
+

... showing only top 20 of 562 rows

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "full_name", children: [], rightAlign: false, values: ["JetBrains/JPS","JetBrains/YouTrackSharp","JetBrains/colorSchemeTool","JetBrains/ideavim","JetBrains/youtrack-vcs-hooks","JetBrains/youtrack-rest-ruby-library","JetBrains/emacs4ij","JetBrains/codereview4intellij","JetBrains/teamcity-nuget-support","JetBrains/Grammar-Kit","JetBrains/intellij-starteam-plugin","JetBrains/la-clojure","JetBrains/MPS","JetBrains/intellij-community","JetBrains/TeamCity.ServiceMessages","JetBrains/youtrack-rest-python-library","JetBrains/intellij-scala","JetBrains/teamcity-messages","JetBrains/teamcity-cpp","JetBrains/kotlin"] }, { name: "stargazers_count", children: [], rightAlign: true, values: ["23","115","290","6120","5","8","47","11","41","534","6","218","1241","12926","39","118","1066","125","27","39402"] }, { name: "topics", children: [], rightAlign: false, values: ["[]","[jetbrains, jetbrains-youtrack, youtr...","[]","[ideavim, intellij, intellij-platform...","[]","[]","[]","[]","[nuget, nuget-feed, teamcity, teamcit...","[]","[]","[]","[domain-specific-language, dsl]","[code-editor, ide, intellij, intellij...","[c-sharp, teamcity, teamcity-service-...","[]","[intellij-idea, intellij-plugin, scala]","[]","[]","[compiler, gradle-plugin, intellij-pl..."] }, -], id: 838860808, rootId: 838860808, totalRows: 562 } ) }); +], id: -1526726645, rootId: -1526726645, totalRows: 562 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860808) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726645) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_6.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_6.html index cb66c45753..18f6790de2 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_6.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_6.html @@ -177,7 +177,7 @@ -
+

... showing only top 20 of 24 rows

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "full_name", children: [], rightAlign: false, values: ["JetBrains/ideavim","JetBrains/MPS","JetBrains/intellij-community","JetBrains/intellij-scala","JetBrains/kotlin","JetBrains/intellij-plugins","JetBrains/Exposed","JetBrains/kotlin-web-site","JetBrains/idea-gitignore","JetBrains/swot","JetBrains/phpstorm-stubs","JetBrains/gradle-intellij-plugin","JetBrains/svg-sprite-loader","JetBrains/resharper-unity","JetBrains/kotlin-native","JetBrains/create-react-kotlin-app","JetBrains/ring-ui","JetBrains/kotlinconf-app","JetBrains/JetBrainsMono","JetBrains/intellij-platform-plugin-te..."] }, { name: "stargazers_count", children: [], rightAlign: true, values: ["6120","1241","12926","1066","39402","1737","5688","1074","1181","1072","1110","1058","1815","1017","7101","2424","2836","2628","6059","1133"] }, { name: "topics", children: [], rightAlign: false, values: ["[ideavim, intellij, intellij-platform...","[domain-specific-language, dsl]","[code-editor, ide, intellij, intellij...","[intellij-idea, intellij-plugin, scala]","[compiler, gradle-plugin, intellij-pl...","[]","[dao, kotlin, orm, sql]","[kotlin]","[gitignore, ignore-files, intellij, i...","[]","[]","[gradle, gradle-intellij-plugin, grad...","[sprite, svg, svg-sprite, svg-stack, ...","[hacktoberfest, jetbrains, plugin, re...","[c, compiler, kotlin, llvm, objective-c]","[create-react-app, jetbrains-ui, kotl...","[components, jetbrains-ui, react]","[]","[coding-font, font, ligatures, monosp...","[intellij, intellij-idea, intellij-id..."] }, -], id: 838860809, rootId: 838860809, totalRows: 24 } ) }); +], id: -1526726644, rootId: -1526726644, totalRows: 24 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860809) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726644) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_7.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_7.html index 96f04f2dad..64e7380cde 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_7.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_7.html @@ -177,7 +177,7 @@ -
+

... showing only top 20 of 24 rows

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "name", children: [], rightAlign: false, values: ["JetBrains/ideavim","JetBrains/MPS","JetBrains/intellij-community","JetBrains/intellij-scala","JetBrains/kotlin","JetBrains/intellij-plugins","JetBrains/Exposed","JetBrains/kotlin-web-site","JetBrains/idea-gitignore","JetBrains/swot","JetBrains/phpstorm-stubs","JetBrains/gradle-intellij-plugin","JetBrains/svg-sprite-loader","JetBrains/resharper-unity","JetBrains/kotlin-native","JetBrains/create-react-kotlin-app","JetBrains/ring-ui","JetBrains/kotlinconf-app","JetBrains/JetBrainsMono","JetBrains/intellij-platform-plugin-te..."] }, { name: "starsCount", children: [], rightAlign: true, values: ["6120","1241","12926","1066","39402","1737","5688","1074","1181","1072","1110","1058","1815","1017","7101","2424","2836","2628","6059","1133"] }, { name: "topics", children: [], rightAlign: false, values: ["[ideavim, intellij, intellij-platform...","[domain-specific-language, dsl]","[code-editor, ide, intellij, intellij...","[intellij-idea, intellij-plugin, scala]","[compiler, gradle-plugin, intellij-pl...","[]","[dao, kotlin, orm, sql]","[kotlin]","[gitignore, ignore-files, intellij, i...","[]","[]","[gradle, gradle-intellij-plugin, grad...","[sprite, svg, svg-sprite, svg-stack, ...","[hacktoberfest, jetbrains, plugin, re...","[c, compiler, kotlin, llvm, objective-c]","[create-react-app, jetbrains-ui, kotl...","[components, jetbrains-ui, react]","[]","[coding-font, font, ligatures, monosp...","[intellij, intellij-idea, intellij-id..."] }, -], id: 838860810, rootId: 838860810, totalRows: 24 } ) }); +], id: -1526726643, rootId: -1526726643, totalRows: 24 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860810) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726643) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_8.html b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_8.html index d325a157cc..19718450ae 100644 --- a/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_8.html +++ b/docs/StardustDocs/resources/guides/quickstart/notebook_test_quickstart_8.html @@ -177,7 +177,7 @@ -
+

... showing only top 20 of 24 rows

@@ -460,10 +460,10 @@ call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "name", children: [], rightAlign: false, values: ["ideavim","MPS","intellij-community","intellij-scala","kotlin","intellij-plugins","Exposed","kotlin-web-site","idea-gitignore","swot","phpstorm-stubs","gradle-intellij-plugin","svg-sprite-loader","resharper-unity","kotlin-native","create-react-kotlin-app","ring-ui","kotlinconf-app","JetBrainsMono","intellij-platform-plugin-template"] }, { name: "starsCount", children: [], rightAlign: true, values: ["6120","1241","12926","1066","39402","1737","5688","1074","1181","1072","1110","1058","1815","1017","7101","2424","2836","2628","6059","1133"] }, { name: "\">topics", children: [], rightAlign: false, values: ["[ideavim, intellij, intellij-pl..., ...]","[domain-specific-language, dsl]","[code-editor, ide, intellij, i..., i...]","[intellij-idea, intellij-plugin, scala]","[compiler, gradle-plugin, intel..., ...]","[]","[dao, kotlin, orm, sql]","[kotlin]","[gitignore, ignore-files, intellij, ...]","[]","[]","[gradle, gradle-intellij-plugin, ...]","[sprite, svg, svg-sprite, svg-s..., ...]","[hacktoberfest, jetbrains, plugin, ...]","[c, compiler, kotlin, llvm, objective-c]","[create-react-app, jetbrains-ui, ...]","[components, jetbrains-ui, react]","[]","[coding-font, font, ligatures, ...]","[intellij, intellij-idea, intel..., ...]"] }, -], id: 838860811, rootId: 838860811, totalRows: 24 } ) }); +], id: -1526726642, rootId: -1526726642, totalRows: 24 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(838860811) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726642) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/modify/operations/formatExampleNumbers.html b/docs/StardustDocs/resources/modify/operations/formatExampleNumbers.html index cb9bce2e83..e07554f3cb 100644 --- a/docs/StardustDocs/resources/modify/operations/formatExampleNumbers.html +++ b/docs/StardustDocs/resources/modify/operations/formatExampleNumbers.html @@ -177,7 +177,7 @@ -
+

@@ -467,10 +467,10 @@ { name: "col8", children: [], rightAlign: true, values: [{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "89"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "23"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "56"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "12"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "67"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "90"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "78"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "34"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "45"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "89"}] }, { name: "col9", children: [], rightAlign: true, values: [{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "56"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "67"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "34"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "56"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "23"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "45"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "89"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "78"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "12"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "34"}] }, { name: "col10", children: [], rightAlign: true, values: [{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "43"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "89"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "78"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "23"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "90"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "12"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "67"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "90"},{ style: "background-color:#ffffff;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important", value: "34"},{ style: "background-color:#a9a9a9;color:#ffffff;--text-color:#ffffff !important;--text-color-dark:#ffffff !important;--text-color-pale:#ffffff !important;--text-color-medium:#ffffff !important", value: "78"}] }, -], id: -788529151, rootId: -788529151, totalRows: 10 } ) }); +], id: -1526726652, rootId: -1526726652, totalRows: 10 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(-788529151) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726652) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/modify/operations/formatExample_properties.html b/docs/StardustDocs/resources/modify/operations/formatExample_properties.html index 4c28a12f37..64b9cf7068 100644 --- a/docs/StardustDocs/resources/modify/operations/formatExample_properties.html +++ b/docs/StardustDocs/resources/modify/operations/formatExample_properties.html @@ -177,7 +177,7 @@ -
+

@@ -464,10 +464,10 @@ { name: "city", children: [], rightAlign: false, values: [{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "London"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Dubai"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Moscow"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Milan"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Tokyo"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "null"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Moscow"}] }, { name: "weight", children: [], rightAlign: true, values: [{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#1900e5", value: "54"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#eb0013", value: "87"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "null"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "null"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#72008c", value: "68"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#1f00df", value: "55"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ff0000", value: "90"}] }, { name: "isHappy", children: [], rightAlign: false, values: [{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ff0000", value: "false"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ff0000", value: "false"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"}] }, -], id: 2046820354, rootId: 2046820354, totalRows: 7 } ) }); +], id: -1526726653, rootId: -1526726653, totalRows: 7 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(2046820354) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726653) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/resources/modify/operations/formatExample_strings.html b/docs/StardustDocs/resources/modify/operations/formatExample_strings.html index 94117df20f..a9023ce679 100644 --- a/docs/StardustDocs/resources/modify/operations/formatExample_strings.html +++ b/docs/StardustDocs/resources/modify/operations/formatExample_strings.html @@ -177,7 +177,7 @@ -
+

@@ -464,10 +464,10 @@ { name: "city", children: [], rightAlign: false, values: [{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "London"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Dubai"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Moscow"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Milan"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Tokyo"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "null"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "Moscow"}] }, { name: "weight", children: [], rightAlign: true, values: [{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#1900e5", value: "54"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#eb0013", value: "87"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "null"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ffffff", value: "null"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#72008c", value: "68"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#1f00df", value: "55"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ff0000", value: "90"}] }, { name: "isHappy", children: [], rightAlign: false, values: [{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ff0000", value: "false"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#ff0000", value: "false"},{ style: "font-weight:bold;color:#000000;--text-color:#000000 !important;--text-color-dark:#000000 !important;--text-color-pale:#000000 !important;--text-color-medium:#000000 !important;background-color:#00ff00", value: "true"}] }, -], id: -503316478, rootId: -503316478, totalRows: 7 } ) }); +], id: -1526726651, rootId: -1526726651, totalRows: 7 } ) }); /*-->*/ -call_DataFrame(function() { DataFrame.renderTable(-503316478) }); +call_DataFrame(function() { DataFrame.renderTable(-1526726651) }); function sendHeight() { const table = document.querySelector('table.dataframe'); diff --git a/docs/StardustDocs/topics/convert.md b/docs/StardustDocs/topics/convert.md index 351bd76673..f4d9734b0f 100644 --- a/docs/StardustDocs/topics/convert.md +++ b/docs/StardustDocs/topics/convert.md @@ -70,7 +70,7 @@ df.convert { name }.asColumn { col -> * `LocalDateTime` (kotlinx.datetime and java.time) * `LocalDate` (kotlinx.datetime and java.time) * `LocalTime` (kotlinx.datetime and java.time) -* `Instant` (kotlinx.datetime and java.time) +* `Instant` (kotlinx.datetime, kotlin.time, and java.time) diff --git a/docs/StardustDocs/topics/parse.md b/docs/StardustDocs/topics/parse.md index 5ff7e59423..38d4fe30d2 100644 --- a/docs/StardustDocs/topics/parse.md +++ b/docs/StardustDocs/topics/parse.md @@ -36,6 +36,7 @@ df.parse { age and weight } `parse` tries to parse every `String` column into one of supported types in the following order: * `Int` * `Long` +* `Instant` (`kotlin.time`) (requires `parseExperimentalInstant = true`) * `Instant` (`kotlinx.datetime` and `java.time`) * `LocalDateTime` (`kotlinx.datetime` and `java.time`) * `LocalDate` (`kotlinx.datetime` and `java.time`) @@ -74,6 +75,9 @@ Available parser options: * Enabled by global default * `parseExperimentalUuid: Boolean` is used to enable or disable parsing to the experimental [`kotlin.uuid.Uuid` class](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.uuid/-uuid/). * Disabled by global default +* `parseExperimentalInstant: Boolean` is used to enable or disable parsing to the experimental + [`kotlin.time.Instant` class](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-instant/). + * Disabled by global default diff --git a/examples/idea-examples/unsupported-data-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/multik/multikInsideDataFrame.kt b/examples/idea-examples/unsupported-data-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/multik/multikInsideDataFrame.kt index cfbaa484b0..019f4fd98a 100644 --- a/examples/idea-examples/unsupported-data-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/multik/multikInsideDataFrame.kt +++ b/examples/idea-examples/unsupported-data-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/multik/multikInsideDataFrame.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlinx.dataframe.examples.multik import kotlinx.datetime.LocalDate +import kotlinx.datetime.Month import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.api.append import org.jetbrains.kotlinx.dataframe.api.cast @@ -12,7 +13,6 @@ import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.rand import org.jetbrains.kotlinx.multik.ndarray.data.D3Array import org.jetbrains.kotlinx.multik.ndarray.data.D4Array -import java.time.Month.JULY /** * DataFrames can store anything inside, including Multik ndarrays. @@ -52,7 +52,7 @@ fun main() { // now when we want to check and visualize the T1-weighted MRI scan // for that one healthy patient in July, we can do: val scan = results - .single { scanDate.month == JULY && diagnosis == "Healthy" } + .single { scanDate.month == Month.JULY && diagnosis == "Healthy" } .t1WeightedMri // easy :) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3fcb87c2f3..327369c130 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] ksp = "2.2.0-2.0.2" -kotlinJupyter = "0.13.0-481-1" +kotlinJupyter = "0.15.0-587" ktlint = "12.3.0" @@ -33,7 +33,7 @@ mysql = "9.1.0" postgresql = "42.7.4" sqlite = "3.47.1.0" jtsCore = "1.19.0" -kotlinDatetime = "0.6.1" +kotlinDatetime = "0.7.1-0.6.x-compat" openapi = "2.1.24" kotlinLogging = "7.0.3" sl4j = "2.0.16"